Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

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?

1 decade ago by Husten

perhaps its a solution to change the mousecursor via css when the mouse is over the canvas element?

1 decade ago by Tharuin

I fixed the crosshair thing by just leaving "this.parent();" from the update method of the crosshair entity. I did the same for the health bar entity but it didn't fix it for it. :(
Page 1 of 1
« first « previous next › last »