希望可以帮到刚入坑的新人
直接给小伙伴分享刚完成的源码:
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(this.sprAtlas){
let frames:[cc.SpriteFrame] = this.sprAtlas.getSpriteFrames();

本文介绍了如何在Cocos Creator 1.9版本中使用TypeScript和createWithSpriteFrames动态创建动画组件,解决了编辑器内动画制作的bug问题,提供了源码示例和显示效果。
5866

被折叠的 条评论
为什么被折叠?



