1 decade ago by davidx
Hi,
I am trying to animate a background but I am having no joy.
I have a simple level with my player background collision and a placeholder background (same dimensions as background).
I have a changeState function in main.js and this is where I am trying to add the animation sheet.
As per the doc, I am doing this prior to loading the level (I am using a members director plug in)
My placeholder is a single red square for illustrative purposes and looks like this in the level:
I would expect the above code to have replaced the second tile with the animation, but it remains as a red block. I have tried putting a load of animations, just in case I am missing it, but to no avail:
Can anyone point me in the direction of what I am doing wrong.
NOTE: I have not set the backgrounds to prerender.
Thanks,
D
I am trying to animate a background but I am having no joy.
I have a simple level with my player background collision and a placeholder background (same dimensions as background).
I have a changeState function in main.js and this is where I am trying to add the animation sheet.
var blink = new ig.AnimationSheet('media/hi_res/eyes.png', 64, 64);
this.backgroundAnims['media/hi_res/placeholder.png'] = {
1: new ig.Animation( blink, 0.1, [0,1,2] )
};
//goto next level of exists else game over
if(!this.myDirector.nextLevel()) {
this.changeState(this.STATE.GAMEOVER);
}
As per the doc, I am doing this prior to loading the level (I am using a members director plug in)
My placeholder is a single red square for illustrative purposes and looks like this in the level:
{"name":"placeholder","width":20,"height":10,"linkWithCollision":false,"visible":true,"tilesetName":"media/hi_res/placeholder.png","repeat":true,"distance":"1","tilesize":64,"foreground":false,"data":[[1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
...
I would expect the above code to have replaced the second tile with the animation, but it remains as a red block. I have tried putting a load of animations, just in case I am missing it, but to no avail:
var blink = new ig.AnimationSheet('media/hi_res/eyes.png', 64, 64);
this.backgroundAnims['media/hi_res/placeholder.png'] = {
1: new ig.Animation( blink, 0.1, [0,1,2] ),
11: new ig.Animation( blink, 0.1, [0,1,2] ),
21: new ig.Animation( blink, 0.1, [0,1,2] ),
31: new ig.Animation( blink, 0.1, [0,1,2] ),
41: new ig.Animation( blink, 0.1, [0,1,2] ),
51: new ig.Animation( blink, 0.1, [0,1,2] ),
61: new ig.Animation( blink, 0.1, [0,1,2] ),
71: new ig.Animation( blink, 0.1, [0,1,2] ),
81: new ig.Animation( blink, 0.1, [0,1,2] )
};
Can anyone point me in the direction of what I am doing wrong.
NOTE: I have not set the backgrounds to prerender.
Thanks,
D
