Jump to content

Group falling of game world


isepulveda
 Share

Recommended Posts

So I'm creating a game. When my character falls off the game world, she is reset to the beginning. I've created a group of aliens, and when they fall off the game world, I want them to be added back to the game like I added my main character. Why can't I use the same code as my main character with a group?

Link to comment
Share on other sites

What code are you talking about? It might be useful to show it here!

Can't do much more than warn you: it might happen that you will be resetting the whole group each time any of its parts gets outside of the world if you just replace the player sprite with the aliens groups in your code.

Link to comment
Share on other sites


You could probably solve it  using this example if you are using checkWorldBounds.

Resetting a sprite can normally be done via kill() and reset(). If you are resetting your character this way, then applying the same functions/code to a group object will not work. A group and  a sprite are different type of objects with different properties and methods available.

You can however iterate through each member and reset them using the forEach function:

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...