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

2013/3/12

closing an image

Abdi Abdi

2013/3/12

#
im just programming a game and before the game starts i have an image which should close after i press "enter". i know this is a silly question but every code i type in is wrong :/. thanks for help
danpost danpost

2013/3/13

#
Where is this image: is it a world background or an Actor image? is it set as the default image for where it is used? When 'closing' the image, are you changing worlds? These are questions that would help to determine how to code what you want to do; including information on what is replacing the image, if that applies.
Abdi Abdi

2013/3/13

#
its an actor class, when it closes the user can see the game. the image/actor class is in the world like all the other objects, but it looks like a mainmenu and when i press enter i want nothing to happen but emoving that image, thanks.
danpost danpost

2013/3/13

#
The image belongs to the actor. If you remove the actor, the image goes too. Use the World class method 'removeObject' or 'removeObjects'. You may be able to use the World class method 'getObjects' to list the ones to remove.
Abdi Abdi

2013/3/13

#
yeah thanks alot, it works. but now i have another little problem. when i press space i want it to open a subclass. apparently its not working :/. could you tell me the code to open a new class? if (Greenfoot.isKeyDown("space")) { ??? }
danpost danpost

2013/3/13

#
What do you mean by 'open a subclass'? Please be specific as to what you are trying to do. Explain in detail.
Abdi Abdi

2013/3/13

#
okay, before the game starts there is this mainmenu(whis is just a image), when i press enter it closes and the game starts. but there should be an option to read the instructions. thats why i created another layout, a subclass of the mainmenu, which should open after i press the space button.
danpost danpost

2013/3/13

#
I am not too sure that you want it to be a subclass of mainmenu or just a subclass of Actor. Anyway, to add an actor into the world, use the World class method 'addObject'.
You need to login to post a reply.