Problem with loading a sprite sheet

6 views
Skip to first unread message

dcd018

unread,
May 27, 2012, 9:05:42 AM5/27/12
to eas...@googlegroups.com

Being new to EaselJS, I've used the code from the "Simple Sprite Sheet" example that's packaged with the source zip file. I'm trying to get a sprite sheet to load and play through, but only the first frame appears.

function init() {
   
var stage = new Stage(document.getElementById("canvas"));
   
var ss = new SpriteSheet({
       
"frames": {
           
"width": 159,
           
"numFrames": 71,
           
"regX": 0,
           
"regY": 0,
           
"height": 85
       
},
       
"animations":{
           
"instance1": [0, 0],
           
"images": ["./assets/spritesheet.png"]
       
});

   
var animate = new BitmapAnimation(ss);
    animate
.x = 0;
    animate
.y = 0;

    ss
.getAnimation("instance1").frequency = 2;
    ss
.getAnimation("instance1").next = "instance1";
    animate
.gotoAndPlay("instance1");


    stage
.addChild(animate);
   
Ticker.setFPS(60);
   
Ticker.addListener(stage);
}

I don't think I need a ticker function because I'm not registering any events, I'm just playing from instance1, the frames and canvas are both of equal size. Any suggestions?  Thanks in advance.  

Regards, 

Dan 

Lanny

unread,
May 28, 2012, 1:58:03 PM5/28/12
to eas...@googlegroups.com
Hi Dan,

Your spritesheet appears to only have one animation (instance1), which plays a single frame (from frame 0 to frame 0, which is only 1 frame). If you look at the SimpleSpriteSheet sample, it has frame ranges that are 37 and 25 frames each.

"animations": {"jump": [26, 63], "run": [0, 25]},

Hope that helps.

dcd018

unread,
May 29, 2012, 8:24:02 AM5/29/12
to eas...@googlegroups.com
Thanks. I figured it out, I was under the impression [0,0] was referencing the x, y position of the first frame, not the number of frames the animation consists of.  
Reply all
Reply to author
Forward
0 new messages