在 Adobe Flash 中随着时间的推移减少计时器
Decreasing a timer over time in Adobe Flash
基本上,一旦听到 (3000) 滴答声,我的球就会移动到屏幕上的随机位置。我怎样才能让计时器慢慢减少,让球随着时间的推移移动得越来越快?
var timmyTimer:Timer = new Timer(3000)
timmyTimer.addEventListener(TimerEvent.TIMER, tick)
timmyTimer.start();
function tick(t:TimerEvent):void {
mcBall.x = Math.floor(Math.random() *(stage.stageWidth - mcBall.width));
mcBall.y = Math.floor(Math.random() *(stage.stageHeight - mcBall.height));
mcBall.nextFrame();
关于您现在的问题,3000 毫秒是您的 Timer
对象的 delay
,因此要减小该值,您可以编写:
function tick(t:TimerEvent):void
{
t.target.delay -= 100;
// ...
}
基本上,一旦听到 (3000) 滴答声,我的球就会移动到屏幕上的随机位置。我怎样才能让计时器慢慢减少,让球随着时间的推移移动得越来越快?
var timmyTimer:Timer = new Timer(3000)
timmyTimer.addEventListener(TimerEvent.TIMER, tick)
timmyTimer.start();
function tick(t:TimerEvent):void {
mcBall.x = Math.floor(Math.random() *(stage.stageWidth - mcBall.width));
mcBall.y = Math.floor(Math.random() *(stage.stageHeight - mcBall.height));
mcBall.nextFrame();
关于您现在的问题,3000 毫秒是您的 Timer
对象的 delay
,因此要减小该值,您可以编写:
function tick(t:TimerEvent):void
{
t.target.delay -= 100;
// ...
}