47 lines
1.2 KiB
TypeScript
47 lines
1.2 KiB
TypeScript
|
|
const { ccclass, property } = cc._decorator;
|
|
|
|
@ccclass
|
|
export default class footEff extends cc.Component {
|
|
|
|
@property(cc.Animation)
|
|
ani: cc.Animation = null;
|
|
|
|
|
|
|
|
init(id, dir, scaleX) {
|
|
if (id == 0)
|
|
return;
|
|
if (!this.ani)
|
|
return;
|
|
|
|
let self = this;
|
|
let url = `foot_eff/${id}/${dir}`;
|
|
this.node.scaleX = scaleX;
|
|
cc.loader.loadRes(url, cc.SpriteAtlas, (error, atlas) => {
|
|
if (error) {
|
|
cc.warn(`$警告:加載角色動畫資源失敗${url}`);
|
|
return;
|
|
}
|
|
// @ts-ignore
|
|
let curFrames = atlas.getSpriteFrames();
|
|
let curClip = cc.AnimationClip.createWithSpriteFrames(curFrames, 15);
|
|
curClip.name = "footEff";
|
|
curClip.wrapMode = cc.WrapMode.Normal;
|
|
self.ani.on('stop', self.onStop, self);
|
|
self.ani.addClip(curClip);
|
|
self.ani.play("footEff");
|
|
})
|
|
}
|
|
init2(id, dir, scaleX) {
|
|
this.init(id, dir, scaleX);
|
|
cc.tween(this.node)
|
|
.by(0.5, { position: cc.v2(-80, 80) })
|
|
.start();
|
|
}
|
|
onStop() {
|
|
this.node.destroy();
|
|
}
|
|
// update (dt) {}
|
|
}
|