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

2017/5/2

how to switch between world

FutureCoder FutureCoder

2017/5/2

#
I already know the code to switch to another world. I have an object that when the character touches it, it swaps to another world. But i don't want a lode of objects to switch worlds, one for each world. so i tried this world World = (world) getWorld(); if(getWorld() == world) { if(isTouching(hero.class)) { Greenfoot.setWorld(new world2()); } } for each world inside the object, and it compiled, but when it tried running it gave me an error, so i tried this if(getWorld() == (new world())) { if(isTouching(hero.class)) { Greenfoot.setWorld(new world2()); } } and it compiled but it didn't do anything is there any code i can use that works
danpost danpost

2017/5/2

#
I think you want something like this:
if (getWorld() instanceof world)
FutureCoder FutureCoder

2017/5/2

#
Thanks so much, this really helps
You need to login to post a reply.