我是游戏开发的新手。我使用and-engine 来开发游戏。我创建精灵(例如:- 箭头击中敌人)当用户触摸屏幕时使用场景触摸监听器。我使用移动修改器来移动箭头。但是屏幕上不显示箭头。当我在 log-cat 显示中触摸屏幕时
日志猫错误
10-29 18:36:41.913: V/AndEngine(25704): org.andengine.input.touch.TouchEvent$TouchEventPool<TouchEvent> was exhausted, with 0 item not yet recycled. Allocated 1 more.
10-29 18:36:41.913: V/AndEngine(25704): org.andengine.util.adt.pool.PoolUpdateHandler$1<TouchEventRunnablePoolItem> was exhausted, with 0 item not yet recycled. Allocated 1 more.
代码
private void shootProjectile(final float pX, final float pY) {
int offX = (int) (pX - player.getX());
int offY = (int) (pY - player.getY());
if (offX <= 0)
return;
final Sprite projectile;
// position the projectile on the player
projectile = new Sprite(player.getX(), player.getY(),
arrow.deepCopy(),mEngine.getVertexBufferObjectManager());
mainScene.attachChild(projectile);
int realX = (int) (camera.getWidth() + projectile.getWidth() / 2.0f);
float ratio = (float) offY / (float) offX;
int realY = (int) ((realX * ratio) + projectile.getY());
int offRealX = (int) (realX - projectile.getX());
int offRealY = (int) (realY - projectile.getY());
float length = (float) Math.sqrt((offRealX * offRealX) + (offRealY * offRealY));
float velocity = 480.0f / 1.0f; // 480 pixels / 1 sec
float realMoveDuration = length / velocity;
// defining a move modifier from the projectile's position to the
// calculated one
MoveModifier mod = new MoveModifier(realMoveDuration,projectile.getX(), realX, projectile.getY(), realY);
projectile.registerEntityModifier(mod);
/*projectile.registerEntityModifier(modifier);
PhysicsHandler handler = new PhysicsHandler(projectile);
projectile.registerUpdateHandler(handler);
handler.setVelocity(realX,realY);*/
projectilesToBeAdded.add(projectile);
// plays a shooting sound
}
从上面的代码中,将箭头精灵移动到触摸屏幕的方向。但我无法显示箭头精灵。有人知道请帮我解决这个问题。