This forum is read only and just serves as an archive. If you have any questions, please post them on

1 decade ago by dmen

When using entity.addAnim() I thought it would be nice to be able to specify a frame range instead of only an array of frame numbers. I have a few animations that are 50+ frames long and this would make it quick and easy.

Something like:

this.addAnim('throw', 1, "0-50");

So, I modified animation.js to allow it. If anyone wants to do the same, all you need to do is change line 46, which should read:

this.sequence = sequence;

to the following, and you can use the original array, or a string range like "0-10"

if (typeof (sequence) == "string") {
//string like "0-50"
var seq = [];
var p = sequence.indexOf("-");
var startRange = parseInt(sequence.substring(0, p));
var endRange = parseInt(sequence.substr(p + 1));
for (var i = startRange; i <= endRange; i++) {
this.sequence = seq;
} else {
this.sequence = sequence;

1 decade ago by Xatruch

A clever solution, thanks!

1 decade ago by Joncom

I have removed my original post in order to say the following instead:

I've expanded on dmen's code and made it into a plugin.

What I've added which is not present in dmen's code...

Support for reverse order:
this.addAnim('walk', 0.1, [5,4,3,2,1,0]); // Old
this.addAnim('walk', 0.1, "5-0"); // New

Support for more complicated sequences:
this.addAnim('walk', 0.1, [1,2,3,4,5,0,5,4,3,2]); // Old
this.addAnim('walk', 0.1, "1-5,0,5-2"); // New
Page 1 of 1
« first « previous next › last »