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

2013/6/9

way to make world recognize how many objects are in it?

1
2
erdelf erdelf

2013/6/9

#
oh, you have to call the checkNextLevel method in the act method
Zamoht Zamoht

2013/6/9

#
Wow I thought that beach2 was a pointer. Okay I'm sorry to tell you that I don't think your code is going to work since checkNextLevel(); is called when beach1 is initialized ("created" I guess you can call it that). To keep checking for this you can actually put an act method in your world class and it will work the same way as the actors. Btw make class names with capital in the start. Makes your code easier understanding :)
joeschmoe joeschmoe

2013/6/9

#
ok I added in an act method and put checkNextLevel(); into it. Works like a dream! Thanks a lot erdelf and danpost and zamoht
danpost danpost

2013/6/9

#
The constructor for objects of any class is only executed one time (at the time of its creation). Placing a command (like 'checkNewLevel') there will not be continuously executed (you need to continuously check to see if the new level is valid to go to). This needs to be done in an 'act' method:
public void act()
{
    checkNewLevel();
}
joeschmoe joeschmoe

2013/6/9

#
Thank you thats what I did :P
You need to login to post a reply.
1
2