做游戏多定时器是非常重要。但Director的新加的定时器不合适游戏编写,不过可以编慢速的游戏。长话我不说,主要讨论一下这三个相关的属性:
1. the timer
2. the ticks
3. the milliseconds
从测试中发觉 the milliseconds 更合适,计算更精细。在帧循环中使用更合适,也就解决了速度问题。
property pTime
on prepareframe me
if ( the milliseconds – pTime > 1000 ) then
pTime = the milliseconds
执行内容...
end if
end
一开始就定时计算
property pTime
on beginsprite me
pTime = the milliseconds
end
on prepareframe me