is there a way to get the speed of the scenario.
so something that would return the value which I can set in this command:
Greenfoot.setSpeed(X);
Greenfoot.setSpeed(X);
import greenfoot.*; public class GreenfootSpeed { private static int i_s_Speed=50; public static void set(int i_newSpeed) { Greenfoot.setSpeed(i_newSpeed); i_s_Speed=i_newSpeed; } public static int get() { return i_s_Speed; } }
GreenfootSpeed.set(X);
Greenfoot.setSpeed(X);
GreenfootSpeed.get();
// class field in 'MyWorld' class public static int scenarioSpeed; // in world constructor scenarioSpeed = 60; // or starting speed Greenfoot.setSpeed(scenarioSpeed); // then let's say in an Actor class if(condition == true) { if(MyWorld.scenarioSpeed < 100) { MyWorld.scenarioSpeed++; Greenfoot.setSpeed(MyWorld.scenarioSpeed); } }
// instance field of world public int scenarioSpeed; // in world constructor scenarioSpeed = 60; Greenfoot.setSpeed(scenarioSpeed); // example usage in an Actor class if(condition == true) { MyWorld mw = (MyWorld)getWorld(); if(mw.scenarioSpeed < 100) { mw.scenarioSpeed++; Greenfoot.setSpeed(mw.scenarioSpeed); } }