PixelProgrammer Posted March 2, 2017 Report Share Posted March 2, 2017 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?? Quote Link to comment Share on other sites More sharing options...
samme Posted March 2, 2017 Report Share Posted March 2, 2017 Try orb.world.x orb.world.y // and game.debug.spriteCoords(orb) Quote Link to comment Share on other sites More sharing options...
PixelProgrammer Posted March 2, 2017 Author Report Share Posted March 2, 2017 7 minutes ago, samme said: Try orb.world.x orb.world.y // and game.debug.spriteCoords(orb) @samme you beautiful human being! orb.world was just what I wanted. Thank you! elkranio 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.