Slick Forums

Discuss the Slick 2D Library
It is currently Wed Nov 13, 2019 5:09 pm

All times are UTC




Post new topic Reply to topic  [ 1 post ] 
Author Message
PostPosted: Wed Jan 16, 2013 6:51 pm 
Offline

Joined: Tue May 03, 2011 10:38 pm
Posts: 32
Currently even with detecting the keypress, Android automatically ends the process. I'm trying to detect the back button press in a BasicGameState and use it to go back to a previous state.


Code:
public void keyPressed(int key, char c) {
  // TODO Auto-generated method stub
  System.out.println(key);
  if(key == 131  || key == Input.KEY_BACK || key == 4) // Supposed to be ESC key or back key
  {
    // Set currentState variable to mainmenu and handle in the update function
  }
}


There's some funkyness as it is for detecting keypresses. I use System.out.println() to print the key value being pressed into Logcat, and it's showing key 4. Input.KEY_BACK doesn't even register either, and key == 131 is the escape key for the keyboard when you're running the application on your desktop. I think I brought this up in a previous thread a while ago but I can't remember.

Anyways the main problem here is that the keypress forces the application to enter the if statement in keyPressed(), then hits update() and enters the correct logic there as well, but it doesn't visibly switch states and instead exits. Please let me know if you know a solution.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group