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

2012/6/9

World to move on too the next world after completing the other,

1
2
3
copyrightkid copyrightkid

2012/6/9

#
My game has an actor who you control, the aim is to collect other objects to move up a level. Once all the objects are completed how can i get it to move on to the next level? Thanks
danpost danpost

2012/6/9

#
if (getObjects(Collectable.class).isEmpty()) Greenfoot.setWorld(new NextLevelWorld()); Make 'Collectable' a sub-class of Actor, and all the collectable actors sub-classes of 'Collectable'. When all the collectable items have been collected, there should not be any left in the world; so go to the next level. Put the above line in the world class of each WorldLevel. Just replace 'NextLevelWorld' with the names of the worlds that you want to proceed to.
copyrightkid copyrightkid

2012/6/9

#
Thank you very much, that helped me out alot cheers :)
copyrightkid copyrightkid

2012/6/9

#
It says it cant find symbol 'getobjects' how can i fix it and where did i go wrong
danpost danpost

2012/6/9

#
Java is case-sensitive. You must use 'getObjects'.
copyrightkid copyrightkid

2012/6/10

#
It still says can't find symbol, its odd?
copyrightkid copyrightkid

2012/6/10

#
It is just that part of the coding,
gusbus123 gusbus123

2012/6/10

#
if ur tryign to do this bit of code outside of the world then do it wouldnt work. try using "getWorld().getObjects(Collectable.class);"
copyrightkid copyrightkid

2012/6/10

#
Where is says "getWorld() do i put the world i want it to go to in the ()? , if so that doesnt work it says, Cant find symbol.
danpost danpost

2012/6/10

#
I suggested putting the line in the world classes, but if you happen to prefer it to be in an Actor class, then you need to prefix the method call to 'getObjects' with 'getWorld().'. This lets the compiler know where to find the method (it will assume it to be in the Actor class, otherwise). Nothing goes inside the parenthesis of the 'getWorld()' call. And you do not have to cast it to your sub-class of world, as the method is in 'World', not in your sub-class of world. I still think the proper place for the line is in the act method of each world class that you have (without the 'getWorld().' prefixing).
copyrightkid copyrightkid

2012/6/10

#
If i was to upload the game can you see the coding, if so you can say where i went wrong?
danpost danpost

2012/6/10

#
Sure!
copyrightkid copyrightkid

2012/6/10

#
It's on latest scenarios Animal Food Chain
copyrightkid copyrightkid

2012/6/10

#
http://www.greenfoot.org/scenarios/5439
copyrightkid copyrightkid

2012/6/10

#
how can i let you see the coding?
There are more replies on the next page.
1
2
3