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

2011/7/23

how can i remove a object?

quaddel97 quaddel97

2011/7/23

#
so i made a object that moves and when it hits the edge of the screen it should be removed so i wrote two if commands that check if he is at the edge but what do i have to write in them so that the object gets removed? i wrote it in the object source code does it have to be in the world source code or something?
kiarocks kiarocks

2011/7/23

#
you can write it in both but it is easier in the object class. You type this at the bottom of the act method in your object:
getWorld().removeObject(this);
quaddel97 quaddel97

2011/7/23

#
ahh thank you it works but i have another question: how can i set the scale of an object because i once saw a greenfoot program where you could set the size so it should be possible.
Herman Herman

2011/7/23

#
Scaling the image by a factor 2 after having set the image can be done with: getImage().scale(getImage().getWidth()*2, getImage().getHeight()*2);
You need to login to post a reply.