[LayaAir 2.0]同一个Animation,创建多个实例只能显示一个(测试项目已上传)

描述:
创建了10个sprite,每个sprite里面有一个animation,最终只有第一个sprite的animation能够显示。(跟官方微信飞机结构类似)
 问题截图:
WechatIMG14.jpeg

 
代码:
for (var i:int=0;i<10;i++){
var p:wheel=Pool.getItemByClass("wheel", wheel);
p.pos(i*90+100,200);
p.init();
roleLayer.addChild(p)
}

/////////////wheelas.as

public function wheel(){
this.graphics.drawCircle(0,0,40,"#fff");
_wheel= new Animation();
_wheel.loadAnimation("wheeling.ani");

}

public function init():void{
this.addChild(_wheel);
_wheel.play();
}



 
已邀请:

dejing

赞同来自:

问题已解决,但是原因很奇怪,同一个animation重复创建的时间不能太快
 
通过for循环快速创建了10个wheel的同时,每个wheel也创建了1个animation,这个速度很快。
但是我把程序改为每60帧(1s)或者每10帧创建一个wheel,就能正常为每个wheel添加一个animation。
引擎某个地方有问题吧,因为只有animation有问题,而animaton又使用了缓存池

何吓吓

赞同来自:

你自己打印看看,你这个代码没有创建10个sprite,而是一个sprite里添加了10个wheel(animation)

该问题目前已经被锁定, 无法添加新回复

商务合作
商务合作