[]对象池的使用
private function creatRen(lei):void
{
var url:String
switch(lei){
case 1:
url = "tu/白.png"
break;
case 2:
url = "tu/花旦.png"
break;
case 3:
url = "tu/zhadan.png"
break;
}
var nan:Image = Pool.getItemByClass("nam", Image);
nan.skin = url;
nan.x = Math.random() * 600 + 80;
nan.y =-60;
this.addChild(nan);
}
private function delRen():void
{
if(arr.length){
for (var i:uint = 0; i < arr.length; i++ ){
if (arr[i].y > 800){
Pool.recover("nan", Image);
}
}arr[i].visible = false ;
};
}
{
var url:String
switch(lei){
case 1:
url = "tu/白.png"
break;
case 2:
url = "tu/花旦.png"
break;
case 3:
url = "tu/zhadan.png"
break;
}
var nan:Image = Pool.getItemByClass("nam", Image);
nan.skin = url;
nan.x = Math.random() * 600 + 80;
nan.y =-60;
this.addChild(nan);
}
private function delRen():void
{
if(arr.length){
for (var i:uint = 0; i < arr.length; i++ ){
if (arr[i].y > 800){
Pool.recover("nan", Image);
}
}arr[i].visible = false ;
};
}
没有找到相关结果
已邀请:
要回复问题请先登录
1 个回复
binhuawei
赞同来自: