希望可以帮到刚入坑的新人
直接给小伙伴分享刚完成的源码:
const {ccclass, property} = cc._decorator;
/**
* @author Maniac.guo
* Everyone should have a dream , what if it came true ?
* @className 动画组件(动态创建动画Animation)
* @data 2018年5月18日
* @mailbox 309506117@qq.com
*/
@ccclass
export class AnimationComponent extends cc.Component {
@property(cc.SpriteAtlas)
sprAtlas:cc.SpriteAtlas = null;
@property(Number)
wrapMode:cc.WrapMode = cc.WrapMode.Default;
private _animation:cc.Animation;
public onPlayCallBack:Function = null;
public onStopCallBack:Function = null;
public onFinishedCallBack:Function = null;
onLoad () {
this._animation = this.node.getComponent(cc.Animation);
// console.log(this.sprAtlas);
this.setAnimation();
}
public setAnimation() : void {
let self = this;
if(t