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

2014/6/12

Greenfoot: Image Pass?

Mint_Greenie Mint_Greenie

2014/6/12

#
Hi, I have followed the steps from my previous post. I've made my Paint world and my Game world in one Greenfoot project. My new question is: Is it possible to pass an image? Currently I make the user draw something and then hit a button which opens a dialog asking them if they are ready to play the game. I'm not sure how I can make the 'YES' button pass the image the users have drawn into the Game world, and then switch the world display to the Game world. I appreciate any help! Thank You, Mint_Green
danpost danpost

2014/6/12

#
If the image is to be the background image of the Game world then:
GameWorld gw = new GameWorld();
gw.setBackgound(image);
Greenfoot.setWorld(gw);
Mint_Greenie Mint_Greenie

2014/6/12

#
The image is supposed to be the actor @danpost
danpost danpost

2014/6/12

#
Then access the actor in the newly created world and set its image. Line 2 would only need changed.
gw.getActor().setImage(image);
The 'getActor' method could be written into your GameWorld class to return a reference to the actor or changed to a name of a public field that holds a reference to the actor.
Mint_Greenie Mint_Greenie

2014/6/12

#
thanks
You need to login to post a reply.