开发者

delay in as3 while loop

开发者 https://www.devze.com 2023-02-12 17:31 出处:网络
I am using as3.My sprites are not working correctly on hittestpoint in a wh开发者_JAVA技巧ile loop.I think this is because it is going too fast before it can update the display.So I would like to add

I am using as3. My sprites are not working correctly on hittestpoint in a wh开发者_JAVA技巧ile loop. I think this is because it is going too fast before it can update the display. So I would like to add a delay to the while loop. What is the easiest way to do this?

Like:

while (condition){
MAIN CODE HERE    
CODE FOR DELAY OF 20ms    
}

How can I do a delay in as3?


You could use a Timer instead of the loop.


or a recursive function with some delay built in: I normally use the TweenLite library for a lot of things including things like you´re trying to do..

something like that:

import com.greensock.TweenLite;

recurse();

function recurse():void{

yourCodeHere;

TweenLite.delayedCall(0.02, recurse);

}

0

精彩评论

暂无评论...
验证码 换一张
取 消