Sign in to follow this  

Off Camera items,

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 >{             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. 

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.