isepulveda Posted July 7, 2017 Share Posted July 7, 2017 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 More sharing options...
raaaahman Posted July 8, 2017 Share Posted July 8, 2017 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 More sharing options...
samid737 Posted July 8, 2017 Share Posted July 8, 2017 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 More sharing options...
isepulveda Posted July 11, 2017 Author Share Posted July 11, 2017 Thanks. I created a function and then used it with alien.events.onOutOfBounds.add(this.alienOut, this); Link to comment Share on other sites More sharing options...
Recommended Posts