Jump to content

decrease collision box size


moe091
 Share

Recommended Posts

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

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.

Link to comment
Share on other sites

  • 2 years later...
  • 3 years later...
  • 3 weeks later...

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.

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

Loading...
 Share

  • Recently Browsing   0 members

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