简体   繁体   English

andEngine无法在onSceneTouchEvent中获取ACTION_UP

[英]andEngine Can't get ACTION_UP in onSceneTouchEvent

I'm having some issues with the Scene Touch Listener. 我在使用Scene Touch Listener时遇到了一些问题。 I only receive ACTION_DOWN events. 我只收到ACTION_DOWN事件。 I never get ACTION_UP or ACTION_MOVE events. 我从来没有得到ACTION_UP或ACTION_MOVE事件。 What i did it wrong?. 我做错了什么? Please help me . 请帮我 。

I have overridden the onSceneTouchEvent as follows: 我已经覆盖了onSceneTouchEvent,如下所示:

@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 *注意:我已经返回true但它仍然只有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. 可能是您正在侦听操作并在传播到此侦听器之前处理它(返回true)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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