I have a token actor that's meant to appear whenever a drone is destroyed, and it does, but it instantly gets removed for some reason. I tried just adding a new one manually, and the same thing happened to it every time I run the program. I know the token is gone, because when I right click at the position where it was, it doesn't show up as an option. I posted all of its code here:
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * A green collectible token * * @author (your name) * @version (a version number or a date) */ public class token extends Actor { private int frame = 0; private GreenfootImage t1; private GreenfootImage t2; private GreenfootImage t3; private GreenfootImage t4; private GreenfootImage t5; private GreenfootImage t6; private GreenfootImage t7; private GreenfootImage t8; private GreenfootImage t9; private GreenfootImage t10; public void token() { t1 = new GreenfootImage ("token0.png"); t2 = new GreenfootImage ("token1.png"); t3 = new GreenfootImage ("token2.png"); t4 = new GreenfootImage ("token3.png"); t5 = new GreenfootImage ("token4.png"); t6 = new GreenfootImage ("token5.png"); t7 = new GreenfootImage ("token6.png"); t8 = new GreenfootImage ("token7.png"); t9 = new GreenfootImage ("token8.png"); t10 = new GreenfootImage ("token9.png"); } /** * Act - do whatever the token wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public void act() { animate(); frame = frame + 1; if (frame == 31) { frame = 0; } } private void animate() { if (frame == 3) { setImage(t1); } if (frame == 6) { setImage(t2); } if (frame == 9) { setImage(t3); } if (frame == 12) { setImage(t4); } if (frame == 15) { setImage(t5); } if (frame == 18) { setImage(t6); } if (frame == 21) { setImage(t7); } if (frame == 24) { setImage(t8); } if (frame == 27) { setImage(t9); } if (frame == 30) { setImage(t10); } } }