import SScript from "./SScript"; import { UIPlugin } from "../core/UIPlugin"; import Tween = Laya.Tween; /** 该附加脚本可为宿主提供一个无限循环播放的Tween */ export default class SimpleTween extends SScript{ /** @prop {name:duration, tips:"Tween持续时间,单位毫秒", type:number} */ duration:number = 1000; /** @prop {name:startState, tips:"宿主起始状态时各属性值信息,是一个JSON格式字符串", type:string} */ startState:string = "{}"; /** @prop {name:endState, tips:"宿主终止状态时各属性值信息,是一个JSON格式字符串", type:string} */ endState:string = "{}"; /** @prop {name:yoyo, tips:"播完一次动画后是否需要逆序播放一次", type:boolean} */ yoyo:boolean = true; private _tween:Tween; onEnable(){ let target = this.owner; let startInfo = JSON.parse(this.startState); for(let i in startInfo) { target[i] = startInfo[i]; } this._tween = UIPlugin.loopTween(target, JSON.parse(this.endState), this.duration, 0, this.yoyo); } onDisable(){ this._tween['reset'](true);; } }