[]用xml描述创建一个clip,interval字段妖孽无效
直接上代码
var xml:XML = Laya.loader.getRes("res/config.xml");
xml = xml.firstChild;
for (var node:XML = xml.firstChild; node != null; node = node.nextSibling)
{
var id:Number = node.getAttribute("id");
var clip:Clip = new Clip(node.getAttribute("res") as String);
clip.anchorX = node.getAttribute("anchorX") as Number;
clip.anchorY = node.getAttribute("anchorY") as Number;
clip.name='Ele' +id;
if (node.nodeName == "clip")
{
clip.autoPlay = true;
//妖孽在此,此妖只吃新鲜数字常量,直接上供写上100动画就可以播放,从xml读取出来赋值,动画文丝不动
clip.interval = 100;//node.getAttribute("interval") as int;
//这样写也不行,trace出来是100,还要咋样
//var interv:int = node.getAttribute("interval") as int;
//trace(interv);
//clip.interval = interv;
clip.clipX = node.getAttribute("clipX") as Number;
clip.clipY = node.getAttribute("clipY") as Number;
clip.play();
}
this.ElementView.addChild(clip);
}
config.xml本份规矩,老老实实,勤勤恳恳用utf8编码的,长这个样子
<layout>
<clip id="1" res="res/logo.png" anchorX="0.5" anchorY="0.5" clipX="4" clipY="4" interval="100"/>
<clip id="2" res="res/light1.png" anchorX="0.5" anchorY="0.5" clipX="4" clipY="4" interval="100"/>
<clip id="3" res="res/light2.png" anchorX="0.5" anchorY="0.5" clipX="4" clipY="4" interval="100"/>
<clip id="4" res="res/light3.png" anchorX="0.5" anchorY="0.5" clipX="5" clipY="3" interval="100"/>
<clip id="5" res="res/light4.png" anchorX="0.5" anchorY="0.5" clipX="4" clipY="4" interval="100"/>
</layout>
哪位爷出来评个理?
var xml:XML = Laya.loader.getRes("res/config.xml");
xml = xml.firstChild;
for (var node:XML = xml.firstChild; node != null; node = node.nextSibling)
{
var id:Number = node.getAttribute("id");
var clip:Clip = new Clip(node.getAttribute("res") as String);
clip.anchorX = node.getAttribute("anchorX") as Number;
clip.anchorY = node.getAttribute("anchorY") as Number;
clip.name='Ele' +id;
if (node.nodeName == "clip")
{
clip.autoPlay = true;
//妖孽在此,此妖只吃新鲜数字常量,直接上供写上100动画就可以播放,从xml读取出来赋值,动画文丝不动
clip.interval = 100;//node.getAttribute("interval") as int;
//这样写也不行,trace出来是100,还要咋样
//var interv:int = node.getAttribute("interval") as int;
//trace(interv);
//clip.interval = interv;
clip.clipX = node.getAttribute("clipX") as Number;
clip.clipY = node.getAttribute("clipY") as Number;
clip.play();
}
this.ElementView.addChild(clip);
}
config.xml本份规矩,老老实实,勤勤恳恳用utf8编码的,长这个样子
<layout>
<clip id="1" res="res/logo.png" anchorX="0.5" anchorY="0.5" clipX="4" clipY="4" interval="100"/>
<clip id="2" res="res/light1.png" anchorX="0.5" anchorY="0.5" clipX="4" clipY="4" interval="100"/>
<clip id="3" res="res/light2.png" anchorX="0.5" anchorY="0.5" clipX="4" clipY="4" interval="100"/>
<clip id="4" res="res/light3.png" anchorX="0.5" anchorY="0.5" clipX="5" clipY="3" interval="100"/>
<clip id="5" res="res/light4.png" anchorX="0.5" anchorY="0.5" clipX="4" clipY="4" interval="100"/>
</layout>
哪位爷出来评个理?
没有找到相关结果
已邀请:
要回复问题请先登录
1 个回复
cuixueying
赞同来自: