Created
October 30, 2014 01:15
-
-
Save aaronhampton/bfa4f52bdf786697d011 to your computer and use it in GitHub Desktop.
Enable physics on a Phaser Graphics Circle
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// First, add your sprite and enable physics on it | |
sprite = game.add.sprite(game.world.centerX, game.world.centerY); | |
game.physics.p2.enable(this.sprite); | |
// Create a shape | |
var circObj = new Phaser.Circle(0, 0, 25); | |
// Set the body size of your sprite | |
sprite.body.setCircle(circObj._radius, 0, 0); | |
// Draw the graphics | |
var ring = game.add.graphics(); | |
ring.lineStyle(2, 0x000000, 0.25); | |
ring.drawShape(circObj); | |
// Add the graphics as a child to your sprite | |
sprite.addChild(ring); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment