I created a Jet and a Bullet, and when Jet is touched, the Bullet is fired.
Now I want to know how can I make the Jet fire again when touched after it has fired the first shot?
public class MyGdxGame implements ApplicationListener{ private Texture bulletTexture; private Texture jetTexture; private Stage stage; private JetActor jetActor; private BulletActor bulletActor; int counter=0; float jetX = 700,jetY = 150; float bulletX = jetX-10, bulletY = jetY +43; boolean started; public class JetActor extends Actor{ public JetActor() { setBounds(jetX, jetY, jetTexture.getWidth(), jetTexture.getHeight()); this.addListener(new InputListener(){ public boolean touchDown(InputEvent event, float x, float y, int pointer, int buttons){ stage.addActor(bulletActor); System.out.println(counter); counter++; started = true; return true; } }); } @Override public void draw(Batch batch, float parentAlpha) { batch.draw(jetTexture, jetX, jetY, jetTexture.getWidth(), jetTexture.getHeight()); } } public class BulletActor extends Actor{ @Override public void act(float delta) { } @Override public void draw(Batch batch, float parentAlpha) { batch.draw(bulletTexture,bulletX,bulletY,bulletTexture.getWidth(), bulletTexture.getHeight()); } } @Override public void create() { bulletTexture = new Texture("C:\\Users\\User\\Documents\\LibGdxMainProjects\\SampleGame1\\android\\assets\\bullet.png"); jetTexture = new Texture("C:\\Users\\User\\Documents\\LibGdxMainProjects\\SampleGame1\\android\\assets\\jet.png"); stage = new Stage(); jetActor = new JetActor(); bulletActor = new BulletActor(); stage.addActor(jetActor); Gdx.input.setInputProcessor(stage); } @Override public void dispose() { } @Override public void render() { Gdx.gl.glClearColor(1, 1, 1, 1); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); if(started){ bulletX -=5; } stage.act(Gdx.graphics.getDeltaTime()); stage.draw(); } @Override public void resize ( int width, int height){ } @Override public void pause () { } @Override public void resume () { } }