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

2013/6/2

cannot change the world

kill kill

2013/6/2

#
i have world "background". I want change the world to "level2". i use Greenfoot.setWorld(new level2());. it work, the world is changing. but when i want to add actor in level2, i have error message . "level2 cannot be cast to background"
It would help if you would post the code around the error. However, that error means you are trying to cast something to something it shouldn't be cast. I'm guessing you have the code:
level2 lvl2 = new level2();
(background)lvl2...  //You cannot do this!
If you're just trying to add an actor, you don't need to cast the world. Use addObject(...)
kill kill

2013/6/2

#
i can change the world., but if i want to add actor to this world addObject(new awal(), 20, 20);, it's error. level2 cannot be cast to background. i don't understand what is the meaning cannot cast to background.
kill kill

2013/6/2

#
[Disallowed URL]
danpost danpost

2013/6/2

#
In what class is the error occurring (show the code around which line is highlighted).
You need to login to post a reply.