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++) {
seq.push(i);
}
this.sequence = seq;
} else {
this.sequence = sequence;
}
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++) {
seq.push(i);
}
this.sequence = seq;
} else {
this.sequence = sequence;
}