"Hello world!"
I am trying to remove an object that blocks off the end of my world after i pickup a "Key" item.
I know I am doing something wrong but i can't figure out how i should make it work.
I know "getWorld().removeObject(LevelDetect.class);" does not work, because i need an actor for that.
Does that mean i need to list the LevelDetect's in the world and then call them or is it entirely something else?
Thanks in advance!
I have the following code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | public class Alice extends Mover { private boolean hasKey = false ; public void act() { checkCollisionKey(); checkCollisionLevel(); checkHasKey(); } public void checkCollisionKey() { Actor collided; collided = getOneIntersectingObject(Key. class ); if (collided != null ) { hasKey= true ; getWorld().removeObject(collided); getWorld().addObject( new Key2(), 180 , 10 ); } } private void checkHasKey() { if (hasKey != true ) { getWorld().removeObject(LevelDetect. class ); } } private void checkCollisionLevel() { Actor collided; collided = getOneIntersectingObject(LevelDetect. class ); if (collided != null ) { setLocation(getX()- 1 , getY()); } } |