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 Silent

Hello.

I have a UI entity that I want to draw things such as HP, MP and gold on. I copied the code form Impact's Hello World, but it doesn't seem to work.

EntityUiIdle = ig.Entity.extend({

	size: {x: 160, y: 32},

	animSheet: new ig.AnimationSheet('media/uiIdle.png', 160, 32),

	font: new ig.Font( 'media/04b03.font.png' ),

	
	init: function (x, y, settings) {
		this.parent(x, y, settings);

		this.addAnim('default', 1, [0]);

		ig.game.spawnEntity(EntityPortrait, 1, 102, this.zIndex + 1);
		ig.game.spawnEntity(EntityClass, 1, 93, this.zIndex + 1);

		ig.game.sortEntitiesDeferred();
	},

	update: function () {
		this.parent();

		this.font.draw("Hello World!!", 1, 110);
	}
});

Can someone please help me find out what's wrong?

Thanks in advance.

1 decade ago by end3r

You should put your drawing of the font in a draw() method instead of update().

Just add this:
    draw: function () {
        this.parent();
        this.font.draw("Hello World!!", 1, 110);
    }

1 decade ago by Silent

Oh, lol. Thanks that fixed it :)

1 decade ago by end3r

Sure, glad I could help :)

I wish my problems were only that easy to solve :D
Page 1 of 1
« first « previous next › last »