Jump to content

How to find position of child sprite relative to world?


PixelProgrammer
 Share

Recommended Posts

Hi there!

 So here's my issue. I have a player sprite which has an orb sprite attached to it as a child. 

Player = function (game, x, y, image) {

    Phaser.Sprite.call(this, game, x, y, image); //calls constructor

    this.orb = this.addChild(game.make.sprite(0, 0, 'orb'));



    game.add.existing(this);
};

/*--------------------------------------------------------*/
Player.prototype = Object.create(Phaser.Sprite.prototype);
Player.prototype.constructor = Player;
/*--------------------------------------------------------*/

I want to reference the x and y positions of the orb so that I can shoot bullets out of it. 

BUT, if I console.log(this.orb.x) or the y position, the value that is returned is 0.

What do I do so that I can get the x and y positions of the orb, relative to the game world and not the parent sprite??

orbAndPlayer.png.66c17b7617d37769536646be7924c6cd.png 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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