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

2012/4/12

Is there a way to change a scenarios speed with programing?

drhorriblejr drhorriblejr

2012/4/12

#
Is there a way to change a scenarios speed with coding?
Duta Duta

2012/4/12

#
Greenfoot.setSpeed(...); 100 = the max speed, 50 = halfway, etc.
drhorriblejr drhorriblejr

2012/4/12

#
Thanks Duta! :)
drhorriblejr drhorriblejr

2012/4/12

#
Is there a way to increase the speed like this:
Greenfoot.setSpeed(Getspeed() + 10);
Duta Duta

2012/4/12

#
By the way here's the API link. Its often worth looking through it to see if a method you're looking for exists.
Duta Duta

2012/4/12

#
Not as far as I know.
drhorriblejr drhorriblejr

2012/4/12

#
okay
Duta Duta

2012/4/12

#
What exactly are you trying to do? And also if there was a getSpeed() method (which unless I'm missing something, there isn't), your code should be written more like Greenfoot.setSpeed(Greenfoot.getSpeed() + 10)
danpost danpost

2012/4/12

#
You could add an 'public int runSpeed;' to the world class and in the world constructor, set the value and set the scenario speed at that time. Then when you need the value, you have it right there.
Duta Duta

2012/4/12

#
danpost wrote...
You could add an 'public int runSpeed;' to the world class and in the world constructor, set the value and set the scenario speed at that time. Then when you need the value, you have it right there.
It may also be an idea to make it static for easier access from other classes - I say easier in that you have to do: YourWorld.runSpeed rather than (and this is only if the class extends Actor) ((YourWorld)getWorld()).runSpeed
drhorriblejr drhorriblejr

2012/4/12

#
I think for now I'll just stick with the original method.
You need to login to post a reply.