This site requires JavaScript, please enable it in your browser!
Greenfoot back
ebollinger@sonorahigh.net
ebollinger@sonorahigh.net wrote ...

2018/12/5

shoping trouble

I am starting to make a shop fore my almost finished game and am having trouble figuring out a way fore my player to purchase power ups at any point in the game with being able to return to the level without restarting. P.S. the shop is a difrent world.
danpost danpost

2018/12/5

#
ebollinger@sonorahigh.net wrote...
I am starting to make a shop fore my almost finished game and am having trouble figuring out a way fore my player to purchase power ups at any point in the game with being able to return to the level without restarting. P.S. the shop is a difrent world.
Just set the original world active again. This would require that the shop world retain a reference to the game world. Add a parameter the the constructor of the shop to accept a World object:
// for example
public Shop(World world)
and then use:
// in World subclass (game world)
Greenfoot.setWorld(new Shop(this));

// in Actor subclass
Greenfoot.setWorld(new Shop(getWorld()));
For the Shop world to retain the game world, it will need a World field:
private World gameWorld;
and it will need to be assigned the world in the shop constructor:
gameWorld = world;
To return to the current game, use:
// in shop World subclass
Greenfoot.setWorld(gameWorld);
can you explain that in english please no effence
danpost danpost

2018/12/6

#
ebollinger@sonorahigh.net wrote...
can you explain that in english please no effence
Maybe you should take a look at my World Changing Demo scenario.
You need to login to post a reply.