PixelProgrammer Posted March 2, 2017 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?? Link to comment Share on other sites More sharing options...
samme Posted March 2, 2017 Share Posted March 2, 2017 Try orb.world.x orb.world.y // and game.debug.spriteCoords(orb) Link to comment Share on other sites More sharing options...
PixelProgrammer Posted March 2, 2017 Author 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 Link to comment Share on other sites More sharing options...
Recommended Posts