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 paulh

Hi All

I ve been searching and cant seem to find it, but does anyone know how to draw an entity relative to the screen rather than the co-ordinates of the game world?

or even how to get the entities co-ordinates in screen space?

1 decade ago by Joncom

how to draw an entity relative to the screen rather than the co-ordinates of the game world?

draw: function() {
    var x = ig.system.getDrawPos(this.pos.x);
    var y = ig.system.getDrawPos(this.pos.y);
    this.currentAnim.draw(x, y);
}

how to get the entities co-ordinates in screen space?

var entityPosOnScreen = {
    x: entity.pos.x - ig.game.screen.x,
    y: entity.pos.y - ig.game.screen.y
};

1 decade ago by paulh

wow, many thanks joncom, how did you work that out, i looked through spurce and documents...
Page 1 of 1
« first « previous next › last »