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

2013/3/17

How to put an image in the world

SorrelCeasar SorrelCeasar

2013/3/17

#
i'm trying to put an image in the world after the score reaches 70
danpost danpost

2013/3/17

#
There are several ways to display an image. In your case, if your actors are to 'freeze' when the image is shown, it may be best to use an actor to show the image (just set that image to be that of the actor's). You can use 'getWorld().getObjects(clss)' as a condition for your moving actors to move. If the actor showing the image is not present, then move as normal (else do nothing -- would be understood). If you do not need to show the game background after the score reaches 70, then you can either remove all objects from the world and change the world background or you can instantiate a new world altogether. In either case, if the image is not the background of the world itself, you can draw the image onto the background image, or again, add an actor to the world to show the image. Whatever you do, the code should be located at the point in your scenario where you score in increased. Check its new value and compare it to 70. If it is, process the required actions.
SorrelCeasar SorrelCeasar

2013/3/17

#
Where will i put 'getWorld().getObjects(clss)
danpost danpost

2013/3/17

#
This is only if you are still showing the world and want to 'freeze' actors that continuously move. Let us say that to display this image you created an actor class and named it 'Message'. In those classes whose actors continuously move, change their act methods:
// FROM
public void act()
{
    // your current code
}
// TO
public void act()
{
    if (getWorld().getObjects(Message.class).isEmpty())
    {
        // your current code
    }
}
Now, any time your Message object is showing (or in the world) all actions will be stopped.
SorrelCeasar SorrelCeasar

2013/3/18

#
please like my game
You need to login to post a reply.