AndEngine - 滚动精灵上下 [英] AndEngine - scroll sprites up and down
本文介绍了AndEngine - 滚动精灵上下的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是初学者andengine用户,我需要你的帮助。
我创建扩展精灵类和MySprite的我想要的精灵上下移动在y - 坐标,当我触碰只有精灵与屏幕上滑动手指
我曾尝试通过实施IScrollDetectorListener和IonSceneTouchListener来实现这一点,但问题是:我可以在任何地方摸我的精灵移动
我会很高兴,如果有人可以提供帮助。
有关详细信息,只是发表评论:)
解决方案
MySprite的雪碧=新雪碧(X,Y,textureRegion,this.getVertexBufferObjectManager()){
@覆盖
公共布尔onAreaTouched(最终的TouchEvent pSceneTouchEvent,最终浮动pTouchAreaLocalX,最终浮动pTouchAreaLocalY){ this.setPosition(X,Y);
//将code这里
返回true;
}}; //不要忘记注册您的触摸区域即
mScene.registerTouchArea(MySprite的);
//希望能它可以帮助你。
I am a beginner andengine user and I need your help.
I have created a class MySprite extending sprite and I want the sprite to move up and down on the y - coordinate when I slide with the finger on the Screen by touching only the sprite.
I have tried to achieve this by implementing IScrollDetectorListener and IonSceneTouchListener but the Problem is: I can touch anywhere and my sprites moves.
I would be glad if someone could help.
For more Details just comment :)
解决方案
Sprite mySprite = new Sprite(x, y, textureRegion, this.getVertexBufferObjectManager()) {
@Override
public boolean onAreaTouched(final TouchEvent pSceneTouchEvent, final float pTouchAreaLocalX, final float pTouchAreaLocalY) {
this.setPosition(x, y);
//Insert Code Here
return true;
}};
// dont forgot to register your touch area i.e
mScene.registerTouchArea(mySprite);
// Hoping it may help you.
这篇关于AndEngine - 滚动精灵上下的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文