Say, for example, you wanted to create two instances of ig.Font, both which share the same image: 'media/04b03.font.png'
MyGame = ig.Game.extend({
font1: new ig.Font( 'media/04b03.font.png' ),
font2: new ig.Font( 'media/04b03.font.png' ),
draw: function() {
this.parent();
var x = ig.system.width/2,
y = ig.system.height/2;
this.font1.draw( 'It Works 1!', x, y, ig.Font.ALIGN.CENTER );
this.font2.draw( 'It Works 2!', x, y + 10, ig.Font.ALIGN.CENTER );
}
});
Then let's say you want to modify the letter spacing of one, but not the other...
It's not possible. Modifying one font instance, modifies the other, because they are the same instance. You can't have more instances, due to the way ig.Image caching works.
This works great for images, but not necessarily for fonts.
Perhaps it would make sense for ig.Font to be its own class, and simply have an image property which it reads from, instead of extending from ig.Image.
Say, for example, you wanted to create two instances of
ig.Font
, both which share the same image:'media/04b03.font.png'
Then let's say you want to modify the letter spacing of one, but not the other...
It's not possible. Modifying one font instance, modifies the other, because they are the same instance. You can't have more instances, due to the way
ig.Image
caching works.This works great for images, but not necessarily for fonts.
Perhaps it would make sense for
ig.Font
to be its own class, and simply have animage
property which it reads from, instead of extending fromig.Image
.