0

Have any way to create the frames repeated like this, above:

character = new createjs.SpriteSheet({
        images: [img],
        frames: {width: frameW, height: frameH, regX: frameW/2, regY: frameH/2},
        animations: { run: [0,9, "run"],
                      hit: [10,10,11,11,12,12,13,13,14,14,15,15, "idle"],
                      jmp: [18,22, "idle_jmp"],
                      idle_jmp: [22],
                      idle: [2]
             }
    });

Repeating each frame on hit twice, to simulate lower FPS just on hit action heappens!

scel.pi
  • 703
  • 6
  • 9

2 Answers2

2

In addition to the code-based frequency solution provided by olsn, you can specify a "frequency" in the SpriteSheet data as well.

The format for your sample "hit" animation is incorrect. You can either us a simple format:


hit: [startFrame, endFrame, "nextAnimation", frequency],
// For example:
hit: [10,15,"idle",2]

Or you can use a more complex definition with each frame, and specify the other properties by name:


hit: {
    frames: [10,11,12,13,14,15],
    next: "idle",
    frequency:2
}

Check out the main overview in the SpriteSheet docs: http://www.createjs.com/Docs/EaselJS/classes/SpriteSheet.html

Lanny
  • 11,244
  • 1
  • 22
  • 30
1

You could use:

character.getAnimation('run').frequency = 2 or whatever frequency you like

You can set that during runtime for each individual animation.

olsn
  • 16,644
  • 6
  • 59
  • 65