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

2017/2/10

Remove string after the button was pressed.

AlexandraEn AlexandraEn

2017/2/10

#
How do I remove a string after a button has been pressed?
valdes valdes

2017/2/11

#
That "string", is it an Actor object, a GreenfootImage object, a Label object,...? in any case, you need a reference variable to have access to that object. That variable should be in your World class as a member variable. In the constructor of your world, you instanciate that variable, and add it to the world. Same with the button. In the button code, you check for the mouse click, get the world from the button and remove the object string. There are several ways to do that, the string as a public variable or a public method inside the world that removes the string. You can also search for an object from the world reference, using the method getObjects. Your question is very vague, so my answer is generic. If you give more details or code I could help you better.
You need to login to post a reply.