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

2013/6/4

Help with making objects remove themselves in differen scenarious

Creek Creek

2013/6/4

#
Hi i am trying to make it so that if an object is in the world for a certain amount of acts it removes itself, or if a character (Sonic) runs against it for a certain amount of acts it gets removed. At the moment i am trying to use the canSee method but that requires you to be on the object, how can i do this to make it so that a counter runs if my character is one coordinate away from the object? void remove() { if ( canSee(Sonic.class)) { iceCounter = iceCounter+1; } else if ( !canSee(Sonic.class)) { iceCounter = 0; iceMelter = iceMelter++; } if ( canSee(Sonic.class) && iceCounter == 30 ) { getWorld().removeObject(this); iceCounter = 0; } if ( iceMelter == 100 ) { getWorld().removeObjects(getWorld().getObjects(IceBrick.class)); } }
You need to login to post a reply.