56 lines
2.2 KiB
TypeScript
56 lines
2.2 KiB
TypeScript
import FrameAnimation from "./FrameAnimation";
|
|
|
|
// Learn TypeScript:
|
|
// - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/typescript.html
|
|
// - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/typescript.html
|
|
// Learn Attribute:
|
|
// - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
|
|
// - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/reference/attributes.html
|
|
// Learn life-cycle callbacks:
|
|
// - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
|
|
// - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/life-cycle-callbacks.html
|
|
|
|
const {ccclass, property} = cc._decorator;
|
|
|
|
@ccclass
|
|
export default class FramaAnimations extends cc.Component {
|
|
|
|
private curPlayIndex:number = 0;
|
|
|
|
init () {
|
|
for (let index = 0; index < this.node.childrenCount; index++) {
|
|
this.node.children[index].getComponent<FrameAnimation>(FrameAnimation).init()
|
|
}
|
|
}
|
|
|
|
Play(index:number,speed:number = 20,loopCount:number = -1,startFrame:number = 0,callBack:cc.ActionInstant = null){
|
|
|
|
let lastAnima = this.node.children[this.curPlayIndex].getComponent<FrameAnimation>(FrameAnimation);
|
|
lastAnima.stop();
|
|
|
|
this.curPlayIndex = index;
|
|
let curAnima = this.node.children[this.curPlayIndex].getComponent<FrameAnimation>(FrameAnimation);
|
|
curAnima.Play(speed,loopCount,startFrame,callBack);
|
|
}
|
|
|
|
setPlaySpeed(speed:number = 20){
|
|
let curAnima = this.node.children[this.curPlayIndex].getComponent<FrameAnimation>(FrameAnimation);
|
|
curAnima.setPlaySpeed(speed)
|
|
}
|
|
|
|
setLoopCallBack(loopCallBack:cc.ActionInstant){
|
|
let curAnima = this.node.children[this.curPlayIndex].getComponent<FrameAnimation>(FrameAnimation);
|
|
curAnima.setLoopCallBack(loopCallBack)
|
|
}
|
|
|
|
stop(){
|
|
let curAnima = this.node.children[this.curPlayIndex].getComponent<FrameAnimation>(FrameAnimation);
|
|
curAnima.stop();
|
|
}
|
|
|
|
resume(){
|
|
let curAnima = this.node.children[this.curPlayIndex].getComponent<FrameAnimation>(FrameAnimation);
|
|
curAnima.resume();
|
|
}
|
|
}
|