Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions net/flashpunk/Engine.as
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
FP.assignedFrameRate = frameRate;
FP.fixed = fixed;
FP.timeInFrames = fixed;
FP._interval = 1.0 / frameRate;

// global game objects
FP.engine = this;
Expand Down
19 changes: 15 additions & 4 deletions net/flashpunk/FP.as
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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)];
}

Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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.<Number> || object is Vector.<uint> || object is Vector.<int>;
}

// World information.
/** @private */ internal static var _world:World;
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion net/flashpunk/debug/Console.as
Original file line number Diff line number Diff line change
Expand Up @@ -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.<String>)
{
for each (i in properties[0]) WATCH_LIST.push(i);
}
Expand Down
15 changes: 12 additions & 3 deletions net/flashpunk/graphics/Emitter.as
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 3 additions & 4 deletions net/flashpunk/utils/Data.as
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the desired use of clear() just to flush data in memory and not on disk? I feel this is the best approach, but I just want to make sure it is working as intended.

So, to delete a save file, a user would have to do the following:

Data.load("slot1");
Data.clear();
Data.save("slot1");

}

Expand Down