Jump to content
This forum will be closing down. Please move to the respective dedicated project forums.

using Phaser.Graphics as Phaser.Sprite


Harry Miller
 Share

Recommended Posts

I've seen that phaser is able to create Graphics elements and move them around the canvas.

It's easier to create really simple graphics in such way in contrast to create a sprite in a painting program and add it with game.add.Sprite.

 

now the question:

 Can I work with the Graphic object in the same way as Sprites  - even with physics logic ?

 (Can phaser detect collisions between a Graphic and a Sprite ?)

 

 

Link to comment
Share on other sites

No, but you can attach a Graphics object to a Sprite via addChild:

var graphics = game.add.graphics();graphics.boundsPadding = 0; // do this to stop the graphics object having a 10 pixel invisible bordervar sprite = game.add.sprite(game.world.centerX, game.world.centerY, null);sprite.addChild(graphics);// from now on, the graphics will be positioned at 0, 0 relative to the sprite, and if given a body, it should encompass the bounds of the graphics object attached
Link to comment
Share on other sites

  • 9 months later...
 Share

  • Recently Browsing   0 members

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