I am using this code in my car parkinge game, on the actual car to inform the actor to stop at a specific co-ordinate, to update the score and to end the game.
I want to add an object just before the game ends, can I use something as simple as:
or can you only use that in the world
if (getX() == 18 && getY() == 6) { List getSCORE = getWorld(). getObjects (SCORE.class); if (!getSCORE.isEmpty()) { SCORE currScore= (SCORE) getSCORE.get(0); currScore.updateScore(20); } Greenfoot.stop(); }
addObject(new Tree(),19,23); //Adds a Tree to the world at the particular co-ordinate