AndEngine AreaTouched 移动精灵的方法被延迟
我正在使用此方法在 AndEngine 中将精灵从一侧移动到另一侧。
Sprite player = new Sprite(PlayerX,PlayerY, this.mPlayerTextureRegion) {
@Override
public boolean onAreaTouched(final TouchEvent pSceneTouchEvent,
final float pTouchAreaLocalX,
final float pTouchAreaLocalY) {
this.setPosition(pSceneTouchEvent.getX() - this.getWidth() / 2,
this.getY());
return true;
}
};
我注意到的问题是,当精灵快速来回移动时,会出现延迟,有时它不会移动,直到经过修饰和拖动。
有没有办法优化它以获得更好的性能?
I am using this method to move a sprite side to side in AndEngine.
Sprite player = new Sprite(PlayerX,PlayerY, this.mPlayerTextureRegion) {
@Override
public boolean onAreaTouched(final TouchEvent pSceneTouchEvent,
final float pTouchAreaLocalX,
final float pTouchAreaLocalY) {
this.setPosition(pSceneTouchEvent.getX() - this.getWidth() / 2,
this.getY());
return true;
}
};
Thr problem i am noticing is that when the sprite is moved swiftly back and forth there is a delay and sometimes it wont move until retouched and dragged.
Is there anyway to optimize this for better performance?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我已经从 AndEngine 代码中弄清楚了。
不要忘记使用 onAreaTouched() 移动精灵时要
在 LoadScene() 方法末尾调用。
Ive figured it out from the AndEngine code.
Dont forget when using onAreaTouched() to move sprites to call
At the end of your LoadScene() method.