1 decade ago by mattk07
Hello again,
I thought it best to form this as a new question as its related to my last, but on a slightly different angle.
I'm trying to setup an entity to use variables from Weltmeister or if they're not supplied, a default image. ie I change the "fileName" variable in weltmeister to "building1" and this should preload "media/buildings/building1.png".
The problem is though that in the init the variable accurately reports "fileName = building1" but when loaded in game or in WM it throws the error;
Uncaught Failed to load resource: media/buildings/undefined.png
Any idea how I can set the fileName variable to actually be used when creating the animSheet so I can use the preloader to fetch the image.
Thank you in advance!
I thought it best to form this as a new question as its related to my last, but on a slightly different angle.
I'm trying to setup an entity to use variables from Weltmeister or if they're not supplied, a default image. ie I change the "fileName" variable in weltmeister to "building1" and this should preload "media/buildings/building1.png".
The problem is though that in the init the variable accurately reports "fileName = building1" but when loaded in game or in WM it throws the error;
Uncaught Failed to load resource: media/buildings/undefined.png
Any idea how I can set the fileName variable to actually be used when creating the animSheet so I can use the preloader to fetch the image.
Thank you in advance!
ig.module( 'game.entities.building' ) .requires( 'impact.entity' ) .defines(function(){ EntityBuilding = ig.Entity.extend({ size: {x: 96, y:80}, collides: ig.Entity.COLLIDES.FIXED, type: ig.Entity.TYPE.BOTH, _wmScalable: true, _wmDrawBox: true, _wmBoxColor: 'rgba(196, 255, 0, 0.1)', //the fileName variable will be changed in weltmeister to reflect another //image stored in the media/buildings folder such as "building1" or "building2"... etc. fileName: "default", animSheet: new ig.AnimationSheet( 'media/buildings/' + this.fileName + '.png', 96,80 ), init: function( x, y, settings ) { console.log(this.fileName); //this shows up with the correct filename if an image called "undefined.png" //is placed the media/buildings folder so it must get at least this far. this.parent( x, y, settings ); this.addAnim( 'idle', 1.0, [0] ); }, }); });