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

2016/3/30

pop up image after actor ereased

ryvetra ryvetra

2016/3/30

#
i want to pop up image after actor car ereaed(game over) and after that , back to Start Menu how can i do that?
 private void gameOver()
    {
        Actor actor = getOneIntersectingObject(Mobil.class);
        Actor actor2 = getOneIntersectingObject(Mobil2.class);

        if(actor != null || actor2 != null || getWorld() != null && (this.atWorldEdge()))
        {                         
            //Greenfoot.playSound("gameover.wav");
            getWorld().removeObject(this);
            return;
        }
    }
if i put a code after or before return; , its error
ryvetra ryvetra

2016/3/30

#
oh , and yeah . what kind of code should i write to pop up an image in actor class?
Super_Hippo Super_Hippo

2016/3/30

#
Code after 'return' isn't executed, so it doesn't make sense to put code there. However, putting 'return' at the end of a method is redundant. To make an image pop up, you can add an actor to the world which uses this image. Be sure you add the object before line 9 because this line removes the object from the world. 'getWorld().addObject(...' doesn't work anymore because 'getWorld()' returns null.
ryvetra ryvetra

2016/3/30

#
thanks for the explain .. it works :)
You need to login to post a reply.