LibGDX onTouch() method kill on touch
- by johnny-b
How can I add this on my application. i want to use the onTouch() method from the implementation of the InputProcessor to kill the enemies on screen. how do i do that? do i have to do anything to the enemy class? please help Thank you M
@Override
public boolean touchDown(int screenX, int screenY, int pointer, int button) {
return false;
}
here is my enemy class
public class Bullet extends Sprite {
private Vector2 velocity;
private float lifetime;
public Bullet(float x, float y) {
velocity = new Vector2(0, 0);
}
public void update(float delta) {
float targetX = GameWorld.getBall().getX();
float targetY = GameWorld.getBall().getY();
float dx = targetX - getX();
float dy = targetY - getY();
float distToTarget = (float) Math.sqrt(dx * dx + dy * dy);
velocity.x += dx * delta;
velocity.y += dy * delta;
}
}
i am rendering all graphics in a GameRender class and a gameworld class if you need more info please let me know Thank you