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 wicht

Hi there,

If i overwrite the settings of an Entity with a new animSheet (to keep Entities somewhat dynamic and configure them through serverside JSON), i get an DOM Exception 14 (Namespace_Err).

I just traced it down and the problem seems to be the impact.merge method...
it goes down to:

animSheet.image.date.ownerDocument.doctype.prefix

Usecase:

MyGame = ig.Game.extend({
    ...
    	spawnZombie: function() {
		this.nextZombieSpawn = this.getNextZombieSpawn();
		var spawnPos = this.getSpawnPoint();
		var settings = {animSheet: new ig.AnimationSheet('media/zombieDog.png', 32,32)};
		this.spawnEntity(EntityZombie, spawnPos.x, spawnPos.y, settings);
		this.zombies++;
	},
    ...
});

I think the deep copy of the AnimationSheet object is the cause of this problem. Maybe i'm doing it all wrong, but the settings parameter of spawnEntity seemed the right place to dynamically change the animation sheet.

A clue anyone?

1 decade ago by dominic

Mh, yeah, looks like a bug in ig.merge() as it doesn't correctly handle DOM elements (the Image element in the AnimationSheet). I'll fix that!

In the meantime, you can use the following to set the AnimationSheet:

MyGame = ig.Game.extend({
    ...
	spawnZombie: function() {
		this.nextZombieSpawn = this.getNextZombieSpawn();
		var spawnPos = this.getSpawnPoint();
		
		var ent = this.spawnEntity(EntityZombie, spawnPos.x, spawnPos.y, settings);
		ent.animSheet = new ig.AnimationSheet('media/zombieDog.png', 32,32);
		
		this.zombies++;
	},
    ...
});

Edit: Fixed in the current dev version (git repo).
Page 1 of 1
« first « previous next › last »