Open lucap86 opened 8 years ago
ok i've found a solution, in the game update
game.iso.unproject({ x: game.input.activePointer.position.x / game.camera.scale.x, y: game.input.activePointer.position.y / game.camera.scale.y }, game.cursorPos);
do you think that unproject should support camera scale?
Same thing happen when change camera x/y.
this is the fix that i've found:
in update function
this.game.iso.unproject({ x: (this.game.input.activePointer.position.x + this.game.camera.x) / this.game.camera.scale.x, y: (this.game.input.activePointer.position.y + this.game.camera.y) / this.game.camera.scale.y }, this.game.cursorPos);
unproject function
var x = point.x - (this.game.world.x + this.game.camera.x) - (this.game.world.width * this.anchor.x);
var y = point.y - (this.game.world.y + this.game.camera.y) - (this.game.world.height * this.anchor.y) + z
another aproach may be put all into unproject function
var x = ((point.x + this.game.camera.x) / this.game.camera.scale.x) - (this.game.world.x + this.game.camera.x) - (this.game.world.width * this.anchor.x);
var y = ((point.y + this.game.camera.y) / this.game.camera.scale.y) - (this.game.world.y + this.game.camera.y) - (this.game.world.height * this.anchor.y) + z;
Nice work! Making un/projection handle world scaling sounds like a great step forward, maybe make it a pull request?
It's an interesting case - project
and unproject
are meant to be low-level functions for performing basic isometric math on ambiguous coordinates; it doesn't and shouldn't care about scale, offset or anything else. I personally think that although this is a useful addition, it probably shouldn't be added to unproject
but could be added elsewhere. Not entirely sure where though...
@lucap86 that worked for me! thank you <3
Hi, I've the need to scale the camera (zoom-in/out). when i scale it the mouse isometric position is not correctly rescaled.
(try to scale http://rotates.org/phaser/iso/examples/interaction.htm camera as example).
how can i resolve this issue?