Jump to content


Recommended Posts

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. 

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

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.


  • Recently Browsing   0 members

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