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 Hareesun

Got a small hiccup that just doesn't make sense to me.

Basically, I'm trying to have some text be drawn right next to an entity that's part of a level. The problem is using the regular method draws it to the screen instead of the entity layer. Which in turn basically makes it a permanent fixture.

Anyone got any thoughts on a workaround?

NOTE: I've tried using the old this.pos.x, this.pos.y

1 decade ago by Ken

Would putting your Font.draw() in your update function or where ever you are drawing the entity at that moment work? That way you can grab the entity XY and put those values in the Font.draw methods X Y params?

1 decade ago by dominic

I'm not sure I understand your problem, but it sounds like you didn't account for the game's screen position when drawing the text.

Try this in your entity class:
draw: function() {
	this.parent();
	
	var x = this.pos.x - ig.game.screen.x;
	var y = this.pos.y - ig.game.screen.y;
	this.font.draw( 'foo', x, y );
}

1 decade ago by Hareesun

@dominic - Thanks Dom, Once again saved the day. Completely forgot about the game.screen :!

1 decade ago by fugufish

i use this:


Math.abs(this.pos.x-ig.game.screen.x)


making sure it's all positive.
Page 1 of 1
« first « previous next › last »