liakos1992 Posted June 19, 2015 Share Posted June 19, 2015 A have attached a graphic (health bar) above a sprite like this:// sprite is a 50x50 picturevar graphics = PH.add.graphics(10, 10);graphics.lineStyle(2, 0x0000FF, 1);graphics.beginFill(0x00FF08, 0.8);graphics.drawRect(-50, -50, 100, 10);sprite.addChild(graphics);But when the sprite is rotated, the bar is rotated too. I want to attach it to be always above the sprite (around 50 distance) without attatching it manually at update() function Link to comment Share on other sites More sharing options...
Skeptron Posted June 22, 2015 Share Posted June 22, 2015 If I understand well, you put your healthbar into the inner group of your sprite (the character?), so when you apply any change to the sprite its children are also affected. You might want to create a new group (not use the sprite's group) in which you'll put both the sprite and the healthbar, so when you apply changes to the sprite the healthbar will remain unaffected. Or you can also do it without using groups, by adjusting the healthbar's x and y coords at each sprite's update :char.update();healthbar.update(char.x, char.y); Link to comment Share on other sites More sharing options...
Recommended Posts