Harry Miller Posted September 13, 2014 Share Posted September 13, 2014 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 More sharing options...
lewster32 Posted September 13, 2014 Share Posted September 13, 2014 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 liakos1992 1 Link to comment Share on other sites More sharing options...
liakos1992 Posted June 19, 2015 Share Posted June 19, 2015 @lewster32 Is there a way to attach a graphic to a sprite only when moving and not when rotating? I want to create a health bar graphic Link to comment Share on other sites More sharing options...
Recommended Posts