const {ccclass, property} = cc._decorator; @ccclass export default class NewClass extends cc.Component { //需要更多源码联系Q:852183691 //或者 //关注微信公众号“史于二” @property(cc.Prefab) RankInfo:cc.Prefab = null; @property(cc.Node) rannode:cc.Node = null; // LIFE-CYCLE CALLBACKS: Ani = null; Anistate = null; rInfo = null; onLoad () { this.rInfo = cc.instantiate(this.RankInfo); this.rannode.addChild(this.rInfo); } start () { this.PlayAni(); } update (dt) { // cc.systemEvent.on(cc.SystemEvent.EventType.KEY_DOWN,this.onKeyDown,this); } /** * 排行榜的动画播放 */ PlayAni(){ this.Ani = this.rInfo.getComponent(cc.Animation); this.scheduleOnce(function(){ this.Anistate = this.Ani.play(); }) } }