Monday, June 20, 2011

Solution of problem touch input

First, make sure BaseGameAcitvity implement IOnSceneTouchListener. 
Then add setOnSceneTouchListener(this) to your scene. As you register touch listener on whole scene then no matter where you touch onSceneTouchEvent() will be called.
Then, as a part of the interface IOnSceneTouchListener, you will have to implement an operation



public boolean onSceneTouchEvent(Scene pScene, TouchEvent pSceneTouchEvent) {
  if(pSceneTouchEvent.isActionDown){
     .... do stuff 1
     return true; //don't forget this!
  }
  if(pSceneTouchEvent.isActionUp){
     .... do stuff 2
     return true; //don't forget this!
  }
  return false;
}

To make all works fine, don't forget add "return true", 
if you don't add, then ActionUp does not worked and stuff 2 never execute.