Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to make player restrict of boundries in phaser js game?

enter image description here

my code is here ( https://www.codepile.net/pile/7mPpA9m0 ) the player is go out of box of canvans how to make it restrict

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Just call the method setCollideWorldBounds on the players physics object, than the player should not be able to leave, teh Zone.

In the create function just add this line of code: this.player.body.setCollideWorldBounds(true);

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading