1 decade ago by empika
Hallo
Loving the engine so far but I'm having some issue when trying to match an entity's position to the mouse position. Ie, I am trying to make an entity move to where I click.
If I console.log the mouses position and the entity's position, they are completely different.
in entity's update:
For example, if I click in the top left corner of my entity I get:
Mouse: 161 : 121.5
Entity: 96 : 80
I can't understand why this may be, I thought it may be a scaling issue but I am using the default
ig.main( '#canvas', MyGame, 60, 320, 240, 2 );
On a canvas that is 640x480, clicking in the corners gives me a mouse report of 320:240 which is correct. So why is the entity reporting funny x and y coordinates?
Any ideas what might be happening?
Thanks
Loving the engine so far but I'm having some issue when trying to match an entity's position to the mouse position. Ie, I am trying to make an entity move to where I click.
If I console.log the mouses position and the entity's position, they are completely different.
in entity's update:
console.log("Mouse: " + ig.input.mouse.x + " : " + ig.input.mouse.y); console.log("Entity: " + this.pos.x + " : " + this.pos.y);
For example, if I click in the top left corner of my entity I get:
Mouse: 161 : 121.5
Entity: 96 : 80
I can't understand why this may be, I thought it may be a scaling issue but I am using the default
ig.main( '#canvas', MyGame, 60, 320, 240, 2 );
On a canvas that is 640x480, clicking in the corners gives me a mouse report of 320:240 which is correct. So why is the entity reporting funny x and y coordinates?
Any ideas what might be happening?
Thanks