isepulveda

Group falling of game world

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?

Share this post


Link to post
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.

Share this post


Link to post
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:

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.