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

2015/4/12

getWorld(); varaible not working correctly incompatible??

syaqub99 syaqub99

2015/4/12

#
Hi everybody, im new to greenfoot and so im following their tutorials. However, varaiable getWorld() doesn't seem to be matching with my world class. Is there something i've missed out or do I need to use another method? Thank you
public void kill()
    {
        Actor Spider;
        Spider = getOneObjectAtOffset(0, 0, Spider.class);
        if( Spider != null) 
        {
        CastleWorld castleworld;
        castleworld = [b]getWorld();[/b] this bit doesn't work
        castleworld.removeObject(Spider);
            
        }
    }
syaqub99 syaqub99

2015/4/12

#
nvrmind i dont need to use my world name
davmac davmac

2015/4/12

#
In case you do, the way to do it is:
CastleWorld castleworld;
castleworld = (CastleWorld) getWorld();
or just
CastleWorld castleworld = (CastleWorld) getWorld();
You need to login to post a reply.