简体   繁体   中英

andEngine Can't get ACTION_UP in onSceneTouchEvent

I'm having some issues with the Scene Touch Listener. I only receive ACTION_DOWN events. I never get ACTION_UP or ACTION_MOVE events. What i did it wrong?. Please help me .

I have overridden the onSceneTouchEvent as follows:

@Override
public boolean onSceneTouchEvent(final Scene pScene,
        final TouchEvent pSceneTouchEvent) {
    switch (pSceneTouchEvent.getAction()) {
    case TouchEvent.ACTION_DOWN:
        Log.d(TAG, "onSceneTouchEvent # ACTION_DOWN");
        break;
    case TouchEvent.ACTION_UP:
        Log.d(TAG, "onSceneTouchEvent # ACTION_UP");
        break;
    }
    return true;
}

*notice :I return true already but it still get only ACTION_DOWN

never use switch case. because it will choose only one case, and action down is the first action, it will choosen forever.. the other action will ignored.

use this instead:

if(pSceneTouchEvent.isActionDown){
   //code action down here
}
if(pSceneTouchEvent.isActionMove){
   //code action move here
}
if(pSceneTouchEvent.isActionUp){
   //code action up here
}

Are you listening to scene touch events anywhere else? It could be that you are listening to action up and handling it there (returning true) before it propagates to this listener.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM