srikarg Posted March 15, 2014 Share Posted March 15, 2014 Hello all, I have two simple questions. First of all, is it possible to collide a Phaser.Sprite with a Phaser.Rectangle? If not, is it possible to collide two Phaser.Rectangles? Thanks in advance... Link to comment Share on other sites More sharing options...
srikarg Posted March 15, 2014 Author Share Posted March 15, 2014 I'm creating a game with two players (Phaser.Sprite) and one floor (Phaser.Rectangle)...I just need the players to collide with the floor... Link to comment Share on other sites More sharing options...
evan312 Posted March 15, 2014 Share Posted March 15, 2014 I'm not sure if you can collide a rectangle with a sprite, but my advice would to make both the player and the floor sprites then handle the collision using whichever physics system you want to use. Link to comment Share on other sites More sharing options...
eugenioclrc Posted March 16, 2014 Share Posted March 16, 2014 Yes its totally posible; Put in your create function:this.floor = this.game.add.sprite(0, 678);this.physics.enable(this.floor, Phaser.Physics.ARCADE);this.floor.body.immovable = true;this.floor.body.width = this.game.world.width;Then in your update function add;this.game.physics.arcade.collide(this.floor, this.YOURSPRITENAME);I have used this in my game; Play:http://eugenioclrc.github.io/circushtml5/ Source;https://github.com/eugenioclrc/circushtml5 Gods 1 Link to comment Share on other sites More sharing options...
Cedric Posted November 28, 2014 Share Posted November 28, 2014 @eugenioclrc How did you you make the half of the fire hoop render behind and the auther in front of the player ? Link to comment Share on other sites More sharing options...
Lyian Posted September 10, 2015 Share Posted September 10, 2015 Just for completion: By defing in the create() function one sprite before the other lets the sprite appear above one. Link to comment Share on other sites More sharing options...
Recommended Posts