weratius Posted February 29, 2016 Share Posted February 29, 2016 Hello, guys! I have a tilesprite on a background: function createSpace() { var space = game.add.tileSprite(0, 0, game.width, game.height, 'space'); space.fixedToCamera = true; space.inputEnabled = true; space.events.onInputDown.add(this.goToPointer); layers.backgroundLayer.add(space); return space; } spaceSystem.prototype.update = function() { //here I move a tilesprite when I user arrows if(this.space != null) { this.space.tilePosition.set(game.camera.x * -0.5, game.camera.y * -0.5); } } Because this method returns my screen coordinates: var myObject = this; spaceSystem.prototype.goToPointer = function() { var x = game.math.snapToFloor(game.input.x, 6080) / 6080; var y = game.math.snapToFloor(game.input.y, 6080) / 6080; myObject.myShip.ship.x = x; myObject.myShip.ship.y = y; console.log(x, y); //1071, 801 } But it must be 3000 and 2000 for example The width and the height of my tilesprite = 6080 I have a question: how can I get the absolute coordinates of a click pointer on a tilesprite? Thank you in advance Link to comment Share on other sites More sharing options...
drhayes Posted February 29, 2016 Share Posted February 29, 2016 I *think* you're looking for Phaser.Input.worldX and worldY, as in "game.input.worldX". Because yeah, you're right, .x and .y are relative to the parent. Link to comment Share on other sites More sharing options...
Recommended Posts