Я новичок в разработке игр. Я использую and-engine для разработки игры. Создаю спрайт (пример: - стрелка, чтобы поразить врага), когда пользователь касается экрана, использует прослушиватель касания сцены. Я использую модификатор движения для перемещения стрелки. Но стрелка не отображается на экране. Когда я касаюсь экрана в лог-кот показывает
Ошибка журнала 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
}
из приведенного выше кода переместите спрайт со стрелкой в направление, где бы вы ни касались экрана. Но я не могу отобразить спрайт со стрелкой. Может ли кто-нибудь знать, пожалуйста, помогите мне решить эту проблему.