【发布时间】:2014-08-05 14:37:47
【问题描述】:
我正在尝试制作一个精灵,所以当您触摸它并拖动手指时,精灵会跟随您的动作。我尝试遵循 AndEngine 示例,但它们是 GLES1 的一部分。我正在使用 GLES2。
在我的代码中,onAreaTouched 被调用,但它并没有被持续调用来用我的手指更新精灵。
提前致谢。
public class RectangleFactory extends Sprite {
public float randomNumber;
public RectangleFactory(float pX, float pY, ITextureRegion pTextureRegion,
VertexBufferObjectManager pVertexBufferObjectManager) {
super(pX, pY, pTextureRegion, pVertexBufferObjectManager);
// TODO Auto-generated constructor stub
Random random = new Random();
randomNumber = (float) random.nextInt(BallShakeActivity.CAMERA_WIDTH);
};
@Override
public boolean onAreaTouched(TouchEvent pSceneTouchEvent, float X, float Y)
{
Log.d("Mark", "circles are touched");
this.setPosition(pSceneTouchEvent.getX() - this.getWidth() / 2, pSceneTouchEvent.getY() - this.getHeight() / 2);
if(pSceneTouchEvent.isActionMove()){
Log.d("Mark", "finger is moving");
}
return true;
};
@Override
protected void onManagedUpdate(final float pSecondsElapsed){
if(this.mY > 0f){
}
else{
Random random = new Random();
randomNumber = (float) random.nextInt(BallShakeActivity.CAMERA_WIDTH);
this.setPosition(randomNumber, 800f);
}
super.onManagedUpdate(pSecondsElapsed);
}
}
【问题讨论】:
标签: andengine