You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
1.2 KiB
39 lines
1.2 KiB
2 years ago
|
import { Player } from "./base.js";
|
||
|
import { GIF } from '/static/js/utils/gif.js';
|
||
|
export class Kyo extends Player{
|
||
|
constructor(root,info) {
|
||
|
super(root,info);
|
||
|
this.init_animations();
|
||
|
}
|
||
|
|
||
|
init_animations() {
|
||
|
let outer = this; // 要在下面的function中使用必须保存当前的this
|
||
|
let offsets = [0,-10,-10,0,0,0,0];
|
||
|
// 总共有七个动作
|
||
|
for (let i = 0 ; i < 7; i++) {
|
||
|
let gif = new GIF();
|
||
|
gif.load(`/static/images/player/kyo/${i}.gif`); // gif->images
|
||
|
this.animations.set(i, {
|
||
|
gif: gif,
|
||
|
frame_cnt: 0, // 总图片数
|
||
|
frame_rate: 5, // 每5帧过渡一次
|
||
|
offset_y: offsets[i], // y方向偏移量
|
||
|
loaded: false, // 是否加载完成
|
||
|
scale: 2, // 放大多少倍
|
||
|
});
|
||
|
|
||
|
|
||
|
|
||
|
// 加载动画
|
||
|
gif.onload = function() {
|
||
|
let obj = outer.animations.get(i); // 获取第i个动作
|
||
|
obj.frame_cnt = gif.frames.length; // 配置总图片数
|
||
|
obj.loaded = true; // 成功加载
|
||
|
|
||
|
if (i === 3) {
|
||
|
obj.frame_rate = 4;
|
||
|
}
|
||
|
};
|
||
|
}
|
||
|
}
|
||
|
}
|