Search the Community
Showing results for tags 'object kill'.
-
hey guys, so I have been using phaser for a few weeks now. In my game, I have my camera following my character as the progress through a bottom-top level. what I have been trying to do is, have any objects that the player by passes and if the object falls out of camera view, I would like to destroy the object and respawn it higher in the level. I have found a few other posts about this but from the suggestions there, I have not been able to make it work. so far my code for the objects is as follows:- var rPipe = platforms.create(480, 220,'rightpipe'); rPipe.checkWorldBounds=true; rPipe.body.immovable = true; if (rPipe.y > game.camera.y){ rPipe.kill(); } var lPipe = platforms.create(0, 104,'leftpipe'); lPipe.body.immovable = true;As you can see, I have the rPipe checking that it's own position every frame, however if it was to have a greater Y position than the game camera plus the stage height then I would destroy it. Any help would be appreciated and if you need to see more of my code then let me know.
- 1 reply
-
- off camera
- object kill
-
(and 2 more)
Tagged with: