[]特效LOADED监听不到

能给具体点吗新手 ani.once(Laya.Event.LOADED,null,function(ani1){
console.log(ani1.getGraphicBounds());
}); 这样写的话监听不到 现在引擎支持下载功能吗???
已邀请:

cuixueying

赞同来自:

我们测试可以正常获取到宽高,测试代码如下
package
{
import laya.display.Animation;
import laya.display.Stage;
import laya.maths.Rectangle;
import laya.net.Loader;
import laya.utils.Browser;
import laya.utils.Handler;
import laya.webgl.WebGL;

public class LayaAirDemo
{
private const AniConfPath:String = "fighter/fighter.json";

public function LayaAirDemo()
{
// 不支持WebGL时自动切换至Canvas
Laya.init(Browser.clientWidth, Browser.clientHeight, WebGL);
Laya.stage.alignV = Stage.ALIGN_MIDDLE;
Laya.stage.alignH = Stage.ALIGN_CENTER;
Laya.stage.scaleMode = "showall";
Laya.stage.bgColor = "#232628";
Laya.loader.load(AniConfPath, Handler.create(this, createAnimation), null, Loader.ATLAS);
}
private function createAnimation(_e:*=null):void
{
var ani:Animation = new Animation();
ani.loadAtlas(AniConfPath); // 加载图集动画
ani.interval = 30; // 设置播放间隔(单位:毫秒)
ani.index = 1; // 当前播放索引
ani.play(); // 播放图集动画
// 获取动画的边界信息
var bounds:Rectangle = ani.getGraphicBounds();
trace(bounds);
ani.pivot(bounds.width / 2, bounds.height / 2);
ani.pos(Laya.stage.width / 2, Laya.stage.height / 2);
Laya.stage.addChild(ani);
}
}
}
你也可以加个延迟,延迟调用下ani的宽高再试下,如果还不行,可以提供下你的例子,我们看下

要回复问题请先

商务合作
商务合作