Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
因此 ENTER_FRAME 属性将在游戏运行的每一帧上向舞台添加一个对象。如果游戏是 24 fps,每秒创建 24 个对象。我该如何限制它,使其每 4 帧生成一个对象?
你可以有一个每帧递增的计数器
var f:int = 0; addEventListener(Event.ENTER_FRAME,onEnterFrame); function onEnterFrame(e:Event):void{ if (f%4 == 0){ // do something } f++; }
如果你愿意,你可以f=0;在 if 语句中设置
f=0;