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

2012/5/21

Adding an object

Matt Matt

2012/5/21

#
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.
           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();  
        }
I want to add an object just before the game ends, can I use something as simple as:
      addObject(new Tree(),19,23); //Adds a Tree to the world at the particular co-ordinate 
or can you only use that in the world
IsVarious IsVarious

2012/5/21

#
All you have to do is place the "addObect..." code right before the "Greenfoot.stop()'
You need to login to post a reply.