我对游戏中的一些循环功能,这个循环开放的9箱,这里的代码延时与的ActionScript环3
function random_item_2(coinsx)
{
var listItem:Array = new Array();
for (var i:uint=0; i<15; i++)
{
listItem.push(i);
}
ItemLeft = 0;
for (var x:uint=0; x<boardWidth; x++)
{
for (var y:uint=0; y<boardHeight; y++)
{
var thisItem:FirstBox = new FirstBox();
thisItem.x = x * IcardHorizontalSpacing + IboardOffsetX;
thisItem.y = y * IcardVerticalSpacing + IboardOffsetY;
var r:int = Math.floor(Math.random() * listItem.length);
thisItem.cardface = listItem[r];
listItem.splice(r,1);
thisItem.gotoAndStop(thisItem.cardface+2);
var itemFound = this.foundItem(thisItem.cardface);
if (itemFound == 50 || itemFound == 100 || itemFound == 250 || itemFound == 500 || itemFound == 1000)
{
var itemC = Number(coinsx) + Number(itemFound);
coinsx = itemC;
update_coins(Number(coinsx));
info_coinstext(String(coinsx));
trace('Gold Coins Found > '+itemFound);
}else if(itemFound!='Kosong'){
updateItem(itemFound);
trace('Item Found > '+itemFound);
}
addChild(thisItem);
ItemLeft++;
}
}
}
的问题是,在一个时间9盒打开,而不是一个一个,我想盒打开包装盒一个接一个,第一个盒子后不久的算法中,我想
open the first box
delay 5 sec
open the second box
delay for 5 sec
我怎么能做到这一点打开,以便接下来的窗口就会打开,在这里?
谢谢@ThomasM,它工作正常,但是当我把它放在循环中似乎不起作用,所有的盒子一次都打开,你有没有想法把锄头放在'for`里? – 2011-12-15 08:54:04