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

2012/3/9

What's wrong with this?

tallyaka tallyaka

2012/3/9

#
I'm trying to make it so that when my boat touches an Island you change worlds. Why isn't this working?
    public void checkWorldChange()
    {
        Island i = (Island)getOneIntersectingObject(Island.class);              if(i != null && Greece2.class.isInstance(getWorld()))
        {
            Greenfoot.setWorld(new CirceLand());
        }
}
mik mik

2012/3/9

#
The problem is the expression Greece2.class.isInstance(getWorld()) I assume you want to check whether the current world object is an instance of class Greece2. You can do this getWorld() instanceof Greece2
tallyaka tallyaka

2012/3/9

#
Oh, thanks!
You need to login to post a reply.