LibGDX onTouch() method kill on touch

Posted by johnny-b on Game Development See other posts from Game Development or by johnny-b
Published on 2014-06-08T20:18:21Z Indexed on 2014/06/08 21:42 UTC
Read the original article Hit count: 197

Filed under:
|
|

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

© Game Development or respective owner

Related posts about java

Related posts about android