0
我有一个名为玩家的动画精灵,我改变了动画和使用onscreencontrol的方向。动画似乎卡住和/或重复第一帧,而没有经历完整的动画周期。我怀疑屏幕控制更新处理程序是否有时间完成所有步骤之前重置动画?我不知道什么是错在这里,这似乎像它应该工作:Android AndEngine动画精灵没有正确动画
final AnalogOnScreenControl velocityOnScreenControl = new AnalogOnScreenControl(x1, y1, this.BoundChaseCamera,this.ScreenControlBaseTextureRegion,this.ScreenControlKnobTextureRegion, 0.1f,new IAnalogOnScreenControlListener() {
@Override
public void onControlChange(
final BaseOnScreenControl pBaseOnScreenControl,
final float pValueX, final float pValueY) {
/* player position */
float spotX = player.getX() + 1 * TILE_WIDTH * pValueX;
float spotY = player.getY() + 1 * TILE_HEIGHT * pValueY;
/* if player position within bounds of map */
if (spotX < TMXMapLayer.getWidth()
&& spotY < TMXMapLayer.getHeight()
&& spotX >= 0 && spotY >= 0) {
/* Set player velocity */
final Vector2 velocity = Vector2Pool.obtain(pValueX * 3, pValueY * 3);
PlayerBody.setLinearVelocity(velocity);
Vector2Pool.recycle(velocity);
/* Math to determine the direction of movement */
double dirDouble = (Math.atan2(pValueX, pValueY)
/(Math.PI/2) + 2);
float direction = (int) Math.round(dirDouble)
% DirectionState;
/* if movement is N,E,S or W, do animation */
if (direction == 0) { // If Go North
player.animate(new long[] { 200, 200, 200 }, 0,2, true); // north
} else if (direction == 1) { // If Go West
player.animate(new long[] { 200, 200, 200 }, 9,11, true); // west
} else if (direction == 2) { // If Go South
player.animate(new long[] { 200, 200, 200 }, 6,8, true); // south
} else if (direction == 3) { // If Go East
player.animate(new long[] { 200, 200, 200 }, 3,5, true); // east
}
}
}
是什么DirectionState变量? – user2080866 2013-02-20 15:53:11