This site requires JavaScript, please enable it in your browser!
Greenfoot back
Ryan478
Ryan478 wrote ...

2018/7/27

Greenfoot lagging then screen turning white

Ryan478 Ryan478

2018/7/27

#
is there something wrong with my code that is making green foot glitch? public class Projectile extends Actor { int x; public Projectile() { setRotation(270); } public void act() { hit(); ProjectileInterval(); move(5); } public void ProjectileInterval() { x = ((x+1)%25); if (x == 0) { shoot(); } } public void shoot() { getWorld().addObject(new Projectile(), 400, 475); } public void hit() { if (isTouching(Space_Invader.class)) { removeTouching(Projectile.class); } } }
Super_Hippo Super_Hippo

2018/7/27

#
Who is shooting a projectile? Maybe a gun, but not a projectile. So don't add the projectile from the Projectile class. The code won't execute when it isn't in the world.
Ryan478 Ryan478

2018/7/27

#
thanks
You need to login to post a reply.