1 decade ago by Tharuin
Heyho!
I'm using an entity for my crosshair following the mouse and a health bar on the top left corner. My problem is that it looks like the crosshair is always a few frames behind the mouse itself and the health bar ( actually a UI element ) always a few frames behind the current "camera".
I'm using the following code in the update methods to update the positions:
Healthbar:
this.pos.x = this.aimedPosition.x + ig.game.screen.x;
this.pos.y = this.aimedPosition.y + ig.game.screen.y;
Crosshair:
var mouseX = ig.input.mouse.x + ig.game.screen.x;
var mouseY = ig.input.mouse.y + ig.game.screen.y;
this.pos.x = mouseX - this.size.x/2;
this.pos.y = mouseY - this.size.y/2;
Is it wrong to use entities for that?
I'm using an entity for my crosshair following the mouse and a health bar on the top left corner. My problem is that it looks like the crosshair is always a few frames behind the mouse itself and the health bar ( actually a UI element ) always a few frames behind the current "camera".
I'm using the following code in the update methods to update the positions:
Healthbar:
this.pos.x = this.aimedPosition.x + ig.game.screen.x;
this.pos.y = this.aimedPosition.y + ig.game.screen.y;
Crosshair:
var mouseX = ig.input.mouse.x + ig.game.screen.x;
var mouseY = ig.input.mouse.y + ig.game.screen.y;
this.pos.x = mouseX - this.size.x/2;
this.pos.y = mouseY - this.size.y/2;
Is it wrong to use entities for that?