Hey. I`m currently working on a small Bomberman game. I want to have a time (300 secs) that will count down to 0 and then resets the game. I made a subclass of an Actor called Text ( by the user danpost) . This looks like this :
Then i created this in my World1 class ( The subclass of World) :
But as soon as i do thath the game starts to become very laggy. Can someone help me out ?
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot, and MouseInfo) public class Text extends Actor { public Text() { this(""); } public Text(String text) { setText(text); } public void setText(String text) { setImage(new GreenfootImage(text, 24, Color.BLACK, new Color(0, 0, 0, 0))); } }
public void act(){ timer--; Text timerText = new Text(); addObject(timerText, 12, 0); timerText.setText("Time left: " + (timer)); Greenfoot.delay(3); removeObject(timerText); if (timer == 0){ Greenfoot.stop(); Greenfoot.setWorld(new World1()); } } }