Аз съм нов в разработката на игри. Използвам and-engine, за да разработя играта. Създавам спрайт (Пример:- стрелка за удряне на врага), когато потребителят докосне екрана, използва слушател за докосване на сцена. Използвам модификатор за движение, за да преместя стрелката. Но стрелката не се показва на екрана. Когато докосна екрана в log-cat показва
Log Cat Error
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
}
от горния код преместете спрайта на стрелката в посоката, където и да докоснете екрана. Но не мога да покажа спрайта на стрелката. Може ли някой да знае, моля, помогнете ми да разреша този проблем.