0 Replies - 5008 Views - Last Post: 20 April 2012 - 09:28 AM

#1 lbgladson  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 43
  • Joined: 04-February 12

Game Development using Java ME

Posted 20 April 2012 - 09:28 AM

I'm not sure that this is the correct place to post this question but I figured I'd give it a try. I am trying to create a mobile game but am having difficulties. I have created a main screen with an implicit list and now I am trying to create a form that displays when the user clicks on the Settings option in the list. I think I have created the correct information on the form but cannot figure out how to make it work when you click on the Settings option.

MainScreen(midlet)
public class MainScreen extends MIDlet implements CommandListener {
  private Display display;

  private List list = new List("The Game:", List.IMPLICIT);

  private Command exit = new Command("Exit", Command.EXIT, 1);

  Alert alert;

  public MainScreen() {
    display = Display.getDisplay(this);

    list.append("New Game", null);
    list.append("High Score", null);
    list.append("Settings", null);
    list.addCommand(exit);
    list.setCommandListener(this);
    
  }

  public void startApp() {
    display.setCurrent(list);
  }

  public void pauseApp() {
  }

  public void destroyApp(boolean unconditional) {
  }

  public void commandAction(Command command, Displayable displayable) {
    if (command == List.SELECT_COMMAND) {
      String selection = list.getString(list.getSelectedIndex());
    } else if (command == exit) {
      destroyApp(false);
      notifyDestroyed();
    }

  }
}



SettingsScreen.java
 public class SettingsScreen extends Form
    {
        private String name;
        private TextField txtName = new TextField("Your Name:", "", 10, TextField.ANY);
        private Command back = new Command("Back", Command.BACK, 2);
        
  private Command cmSettings;
  private Form fmMain;
        public SettingsScreen(String title, MainScreen main, int highscore)
        {
            super(title);
            append(txtName);
            append(new StringItem("Highscore: ", String.valueOf(highscore)));
            addCommand(back);
            this.setCommandListener(main);    
        }
       
    }



Is This A Good Question/Topic? 0
  • +

Page 1 of 1