Jump to content

How to find position of child sprite relative to world?


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'));


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??


Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

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