Skip to content

Impossible to make multiple instances of ig.Font that share common image path #68

Open

Description

@Joncom

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 );
	}
});

download

Then let's say you want to modify the letter spacing of one, but not the other...

Sep-15-2019 01-01-49

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.

Activity

  1. changed the title [-]Impossible to make multiple instances of ig.Font sharing common image path[/-] [+]Impossible to make multiple instances of ig.Font that share common image path[/+] on Sep 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions