diff --git a/net/flashpunk/Engine.as b/net/flashpunk/Engine.as index 79a72bd..f75f64f 100644 --- a/net/flashpunk/Engine.as +++ b/net/flashpunk/Engine.as @@ -63,6 +63,7 @@ FP.assignedFrameRate = frameRate; FP.fixed = fixed; FP.timeInFrames = fixed; + FP._interval = 1.0 / frameRate; // global game objects FP.engine = this; diff --git a/net/flashpunk/FP.as b/net/flashpunk/FP.as index 66c32d8..deca367 100644 --- a/net/flashpunk/FP.as +++ b/net/flashpunk/FP.as @@ -72,6 +72,11 @@ */ public static var elapsed:Number; + /** + * The ideal interval (in fractional seconds) between frames. + */ + public static function get interval():Number { return _interval; } + /** * Timescale applied to FP.elapsed. */ @@ -206,7 +211,7 @@ */ public static function choose(...objs):* { - var c:* = (objs.length == 1 && (objs[0] is Array || objs[0] is Vector.<*>)) ? objs[0] : objs; + var c:* = (objs.length == 1 && (objs[0] is Array || isVector(objs[0]))) ? objs[0] : objs; return c[rand(c.length)]; } @@ -900,7 +905,7 @@ */ public static function shuffle(a:Object):void { - if (a is Array || a is Vector.<*>) + if (a is Array || isVector(a)) { var i:int = a.length, j:int, t:*; while (-- i) @@ -919,7 +924,7 @@ */ public static function sort(object:Object, ascending:Boolean = true):void { - if (object is Array || object is Vector.<*>) + if (object is Array || isVector(object)) { // Only need to sort the array if it has more than one item. if (object.length > 1) @@ -937,7 +942,7 @@ */ public static function sortBy(object:Object, property:String, ascending:Boolean = true):void { - if (object is Array || object is Vector.<*>) + if (object is Array || isVector(object)) { // Only need to sort the array if it has more than one item. if (object.length > 1) @@ -1020,6 +1025,11 @@ if (left < j) quicksortBy(a, left, j, ascending, property); if (i < right) quicksortBy(a, i, right, ascending, property); } + /** @private Determines whether an object is any of the four Vector specializations. */ + private static function isVector(object:Object):Boolean + { + return object is Vector.<*> || object is Vector. || object is Vector. || object is Vector.; + } // World information. /** @private */ internal static var _world:World; @@ -1030,6 +1040,7 @@ // Time information. /** @private */ internal static var _time:uint; + /** @private */ internal static var _interval:Number; /** @private */ public static var _updateTime:uint; /** @private */ public static var _renderTime:uint; /** @private */ public static var _gameTime:uint; diff --git a/net/flashpunk/debug/Console.as b/net/flashpunk/debug/Console.as index 9d23ee6..9c19014 100644 --- a/net/flashpunk/debug/Console.as +++ b/net/flashpunk/debug/Console.as @@ -76,7 +76,7 @@ package net.flashpunk.debug { for each (i in properties) WATCH_LIST.push(i); } - else if (properties[0] is Array || properties[0] is Vector.<*>) + else if (properties[0] is Array || properties[0] is Vector.) { for each (i in properties[0]) WATCH_LIST.push(i); } diff --git a/net/flashpunk/graphics/Emitter.as b/net/flashpunk/graphics/Emitter.as index 45f65a3..9906594 100644 --- a/net/flashpunk/graphics/Emitter.as +++ b/net/flashpunk/graphics/Emitter.as @@ -51,15 +51,24 @@ if (!_particle) return; // particle info - var e:Number = FP.timeInFrames ? 1 : FP.elapsed, - p:Particle = _particle, + var e:Number = FP.timeInFrames ? 1 : FP.elapsed; + simulate(e); + } + + /** + * Simulate the emitter running for a given amount of time. + * @param time The time to run for, in seconds or frames depending on Engine timestep mode. + */ + public function simulate(time:Number):void + { + var p:Particle = _particle, n:Particle; // loop through the particles while (p) { // update time scale - p._time += e; + p._time += time; // remove on time-out if (p._time >= p._duration) diff --git a/net/flashpunk/utils/Data.as b/net/flashpunk/utils/Data.as index 9235856..8b2bd9c 100644 --- a/net/flashpunk/utils/Data.as +++ b/net/flashpunk/utils/Data.as @@ -120,11 +120,10 @@ } /** - * Clears save file. - * @param filename Save file to clear. + * Clears the current data. */ - public static function clear(filename:String):void { - Data.load(filename); + public static function clear():void + { _shared.clear(); }