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

Report as inappropriate.

danpost
danpost presents ...

2013/1/22

Pause World Class

A world class that displays the visual state of another by drawing the calling world's background image and all its actor images on its background in the proper paint order.

Just click on the world to toggle between the 'Go' world and the 'Pause world. A message panel was added to show paused state and a restart counter was added to time the restart after click.

The code also has an example of placing a random number of actors in the world, while randomly choosing the type of actor to add (without using a bunch of 'if else's or a 'switch').

5105 views / 14 in the last 7 days

3 votes | 0 in the last 7 days

Tags: simulation demo with-source class world danpost support pausing

This scenario is a member of: Support Classes by danpost


open in greenfoot
Your browser does not support the canvas tag.
A new version of this scenario was uploaded on Tue Jan 22 22:37:13 UTC 2013 A support class to visually pause a paused world. Added a translucent message panel and a restart counter.
A new version of this scenario was uploaded on Tue Jan 22 23:08:53 UTC 2013 A support class to visually pause a paused world. Minor changes plus added documentation.
A new version of this scenario was uploaded on Thu May 23 04:56:21 UTC 2013 Added missing code. Actors images are more correctly displayed.
A new version of this scenario was uploaded on Thu May 23 04:58:04 UTC 2013 Added missing code. Actors images are more correctly displayed.
A new version of this scenario was uploaded on 2018-10-25 23:33:59 UTC
NahquinNahquin

2018/12/17

Have any couse to use: -if(getX()==0 || getX()==getWorld().getWidth()-1) changeDirection(); and not: isAtEdge/atWorldEdge?
danpostdanpost

2018/12/17

@Nahquin, the scenario was written in 2013 -- before the isAtEdge method was a member of the Actor class.

Want to leave a comment? You must first log in.

Who likes this?

data17 JeppDev davemib123