It works ! Thank you, and for the door and the key: how to bind the door, the key and the player so that the player grab the key, touch the door and the screen and the map change to the next level ?


1 | removeObjects(getObjects( null )); |
1 | removeObjects(getObjects( null )); |
1 2 3 4 5 6 7 8 9 | Actor player = getOneIntersectingObject(Player. class ); if (getX() <= 1 || getX() >= getWorld().getWidth() - 1 ) { getWorld().removeObject( this ); // l'image du kunai est removed } else if (player != null ) { getWorld().removeObject( this ); // pareil } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | private Key key = new Key(); /** * Act - do whatever the Door wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public void act() { if (key.getWorld() == null && isTouching(Player. class )) { // key was picked up and player is at door Level.level++; Greenfoot.setWorld( new Level()); } } public Key getKey() { return key; } |
1 2 3 4 | public void act() { if (isTouching(Player. class )) getWorld().removeObject( this ); } |