How do I make it to where when I shoot that my bullet can only go so far until it dissappears?
private GreenfootImage Fire1 = new GreenfootImage("Fire1.png"); private GreenfootImage Fire2 = new GreenfootImage("Fire2.png"); private GreenfootImage Fire3 = new GreenfootImage("Fire3.png"); private int frame = 1; private double animationCounter = 1; /** * Act - do whatever the FireBall wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public void act() { move(5); fireBallHit(); if(animationCounter % 4 == 0) animateFire(); animationCounter++;// Add your action code here. } public void fireBallHit() { Actor b = getOneIntersectingObject(Alien.class); if(b != null) { getWorld().removeObject(b); getWorld().removeObject(this); } } public void animateFire() { if(frame == 1) { setImage(Fire1); } else if(frame == 2) { setImage(Fire2); } else if(frame == 3) { setImage(Fire3); frame = 1; return; } frame ++; } }
private int fizzleTimer'; private void fizzle() { fizzleTimer++; if (fizzleTimer == /* some number */) getWorld().removeObject(this); }