moe091 Posted February 25, 2014 Share Posted February 25, 2014 Is there any way to decrease the size of the bounding box used for collisions in phaser? Right now I am just implementing my own collision inside phasers callback, essentially using phasers collision as a (slightly)-broad phase collision detection but it'd be cleaner and more efficient if I could just scale the collision box somehow without scaling the actual sprite. Honestly I'm not sure which version of phaser I'm currently using, I downloaded it about a month and a half ago and didn't even pay much attention to it because I didn't expect to make any serious games yet. my current project was just too much fun and I blew it up into a big game(by html5 mobile game standards). Anyway, thanks for any help. And thanks to Rich and everyone who worked on Phaser, it's awesome to work with! Link to comment Share on other sites More sharing options...
jpdev Posted February 25, 2014 Share Posted February 25, 2014 Change the body width / height of the sprite: this.sprite.body.width = 46; this.sprite.body.height = 82;Check if it works by displaying the collision box for the sprite:game.debug.renderPhysicsBody(this.player.sprite.body);You must set phaser to CANVAS Mode to get the debug outputs.var game = new Phaser.Game(1280, 768, Phaser.CANVAS , '', null); Good luck, and don't forget to post your game here on the forums when it's either done or playable and you want feedback. moe091 1 Link to comment Share on other sites More sharing options...
moe091 Posted March 1, 2014 Author Share Posted March 1, 2014 Awesome thanks a lot . Just what I was looking for. And I'll definitely be posting my game in the next few days, it's playable now I just need to add some content and redo graphics. Link to comment Share on other sites More sharing options...
jupo Posted May 1, 2016 Share Posted May 1, 2016 Just an update on this, the API has changed. In the latest version of Phaser (as of May 2016), you should use the following to display the sprite's collision hitbox: game.debug.body(sprite); Also, remember to put this into the render() function. Goshawk 1 Link to comment Share on other sites More sharing options...
beakartJs Posted July 18, 2019 Share Posted July 18, 2019 this.sprite.body.width = 32; I have one question:if I decrease the width of the sprite for example - from 48u to 32u then collision moves by 16u left - how could I center (align) the colission? (8u to left and 8u to right)u - unit Link to comment Share on other sites More sharing options...
elfridaauston87 Posted August 8, 2019 Share Posted August 8, 2019 I really get a solution from jpdev reply. Link to comment Share on other sites More sharing options...
Recommended Posts