Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

more fixes from the github issues queue - pathfinding, system cursors…

…, etc
  • Loading branch information...
commit 69eb96ec578fa77c3be03cabe617b18de4f654aa 1 parent 147f95a
@AdamAtomic authored
View
5 org/flixel/FlxButton.as
@@ -258,7 +258,6 @@ package org.flixel
{
label.x = x;
label.y = y;
- label.scrollFactor = scrollFactor;
}
if(labelOffset != null)
{
@@ -280,7 +279,11 @@ package org.flixel
{
super.draw();
if(label != null)
+ {
+ label.scrollFactor = scrollFactor;
+ label.cameras = cameras;
label.draw();
+ }
}
/**
View
4 org/flixel/FlxEmitter.as
@@ -226,8 +226,8 @@ package org.flixel
on = false;
var i:uint = 0;
var l:uint = _quantity;
- if((l <= 0) || (l > members.length))
- l = members.length;
+ if((l <= 0) || (l > length))
+ l = length;
while(i < l)
{
emitParticle();
View
14 org/flixel/FlxG.as
@@ -368,16 +368,20 @@ package org.flixel
* HOWEVER, <code>FlxU.getRandom()</code> is NOT deterministic and unsafe for use with replays/recordings.
*
* @param Objects A Flash array of objects.
+ * @param StartIndex Optional offset off the front of the array. Default value is 0, or the beginning of the array.
+ * @param Length Optional restriction on the number of values you want to randomly select from.
*
* @return The random object that was selected.
*/
- static public function getRandom(Objects:Array):Object
+ static public function getRandom(Objects:Array,StartIndex:uint=0,Length:uint=0):Object
{
if(Objects != null)
{
- var l:uint = Objects.length;
+ var l:uint = Length;
+ if((l == 0) || (l > Objects.length - StartIndex))
+ l = Objects.length - StartIndex;
if(l > 0)
- return Objects[uint(FlxG.random()*l)];
+ return Objects[StartIndex + uint(FlxG.random()*l)];
}
return null;
}
@@ -629,7 +633,7 @@ package org.flixel
music.pause();
var i:uint = 0;
var sound:FlxSound;
- var l:uint = sounds.members.length;
+ var l:uint = sounds.length;
while(i < l)
{
sound = sounds.members[i++] as FlxSound;
@@ -647,7 +651,7 @@ package org.flixel
music.play();
var i:uint = 0;
var sound:FlxSound;
- var l:uint = sounds.members.length;
+ var l:uint = sounds.length;
while(i < l)
{
sound = sounds.members[i++] as FlxSound;
View
19 org/flixel/FlxGame.as
@@ -16,9 +16,9 @@ package org.flixel
import flash.utils.Timer;
import flash.utils.getTimer;
+ import org.flixel.plugin.TimerManager;
import org.flixel.system.FlxDebugger;
import org.flixel.system.FlxReplay;
- import org.flixel.plugin.TimerManager;
/**
* FlxGame is the heart of all flixel games, and contains a bunch of basic game loops and things.
@@ -40,7 +40,13 @@ package org.flixel
*/
public var useSoundHotKeys:Boolean;
/**
+ * Tells flixel to use the default system mouse cursor instead of custom Flixel mouse cursors.
+ * @default false
+ */
+ public var useSystemCursor:Boolean;
+ /**
* Initialize and allow the flixel debugger overlay even in release mode.
+ * Also useful if you don't use FlxPreloader!
* @default false
*/
public var forceDebugger:Boolean;
@@ -166,11 +172,11 @@ package org.flixel
* @param Zoom The default level of zoom for the game's cameras (e.g. 2 = all pixels are now drawn at 2x). Default = 1.
* @param GameFramerate How frequently the game should update (default is 60 times per second).
* @param FlashFramerate Sets the actual display framerate for Flash player (default is 30 times per second).
+ * @param UseSystemCursor Whether to use the default OS mouse pointer, or to use custom flixel ones.
*/
- public function FlxGame(GameSizeX:uint,GameSizeY:uint,InitialState:Class,Zoom:Number=1,GameFramerate:uint=60,FlashFramerate:uint=30)
+ public function FlxGame(GameSizeX:uint,GameSizeY:uint,InitialState:Class,Zoom:Number=1,GameFramerate:uint=60,FlashFramerate:uint=30,UseSystemCursor:Boolean=false)
{
//super high priority init stuff (focus, mouse, etc)
- flash.ui.Mouse.hide();
_lostFocus = false;
_focus = new Sprite();
_focus.visible = false;
@@ -185,6 +191,9 @@ package org.flixel
_total = 0;
_state = null;
useSoundHotKeys = true;
+ useSystemCursor = UseSystemCursor;
+ if(!useSystemCursor)
+ flash.ui.Mouse.hide();
forceDebugger = false;
_debuggerUp = false;
@@ -242,7 +251,7 @@ package org.flixel
_debuggerUp = _debugger.visible;
if(_debugger.visible)
flash.ui.Mouse.show();
- else
+ else if(!useSystemCursor)
flash.ui.Mouse.hide();
//_console.toggle();
return;
@@ -387,7 +396,7 @@ package org.flixel
*/
protected function onFocus(FlashEvent:Event=null):void
{
- if(!_debuggerUp)
+ if(!_debuggerUp && !useSystemCursor)
flash.ui.Mouse.hide();
FlxG.resetInput();
_lostFocus = _focus.visible = false;
View
9 org/flixel/FlxGroup.as
@@ -518,11 +518,16 @@ package org.flixel
/**
* Returns a member at random from the group.
*
+ * @param StartIndex Optional offset off the front of the array. Default value is 0, or the beginning of the array.
+ * @param Length Optional restriction on the number of values you want to randomly select from.
+ *
* @return A <code>FlxBasic</code> from the members list.
*/
- public function getRandom():FlxBasic
+ public function getRandom(StartIndex:uint=0,Length:uint=0):FlxBasic
{
- return FlxG.getRandom(members) as FlxBasic;
+ if(Length == 0)
+ Length = length;
+ return FlxG.getRandom(members,StartIndex,Length) as FlxBasic;
}
/**
View
14 org/flixel/FlxObject.as
@@ -657,12 +657,14 @@ package org.flixel
{
pathAngle = FlxU.getAngle(_point,node);
FlxU.rotatePoint(0,pathSpeed,0,0,pathAngle,velocity);
- if(_pathRotate) //then set object rotation if necessary
- {
- angularVelocity = 0;
- angularAcceleration = 0;
- angle = pathAngle;
- }
+ }
+
+ //then set object rotation if necessary
+ if(_pathRotate)
+ {
+ angularVelocity = 0;
+ angularAcceleration = 0;
+ angle = pathAngle;
}
}
}
View
7 org/flixel/FlxTilemap.as
@@ -474,8 +474,8 @@ package org.flixel
public function findPath(Start:FlxPoint,End:FlxPoint,Simplify:Boolean=true,RaySimplify:Boolean=false):FlxPath
{
//figure out what tile we are starting and ending on.
- var startIndex:uint = uint((Start.y-y)/_tileHeight) * widthInTiles + uint((Start.x-x)/_tileWidth);
- var endIndex:uint = uint((End.y-y)/_tileHeight) * widthInTiles + uint((End.x-x)/_tileWidth);
+ var startIndex:uint = int((Start.y-y)/_tileHeight) * widthInTiles + int((Start.x-x)/_tileWidth);
+ var endIndex:uint = int((End.y-y)/_tileHeight) * widthInTiles + int((End.x-x)/_tileWidth);
//check that the start and end are clear.
if( ((_tileObjects[_data[startIndex]] as FlxTile).allowCollisions > 0) ||
@@ -596,7 +596,8 @@ package org.flixel
distances[i] = -1;
i++;
}
- var distance:uint = 0;
+ distances[StartIndex] = 0;
+ var distance:uint = 1;
var neighbors:Array = [StartIndex];
var current:Array;
var currentIndex:uint;
View
10 org/flixel/FlxU.as
@@ -160,16 +160,20 @@ package org.flixel
* HOWEVER, <code>FlxU.getRandom()</code> is NOT deterministic and unsafe for use with replays/recordings.
*
* @param Objects A Flash array of objects.
+ * @param StartIndex Optional offset off the front of the array. Default value is 0, or the beginning of the array.
+ * @param Length Optional restriction on the number of values you want to randomly select from.
*
* @return The random object that was selected.
*/
- static public function getRandom(Objects:Array):Object
+ static public function getRandom(Objects:Array,StartIndex:uint=0,Length:uint=0):Object
{
if(Objects != null)
{
- var l:uint = Objects.length;
+ var l:uint = Length;
+ if((l == 0) || (l > Objects.length - StartIndex))
+ l = Objects.length - StartIndex;
if(l > 0)
- return Objects[uint(Math.random()*l)];
+ return Objects[StartIndex + uint(Math.random()*l)];
}
return null;
}
View
2  org/flixel/system/FlxQuadTree.as
@@ -323,7 +323,7 @@ package org.flixel.system
var i:uint = 0;
var basic:FlxBasic;
var members:Array = (ObjectOrGroup as FlxGroup).members;
- var l:uint = members.length;
+ var l:uint = (ObjectOrGroup as FlxGroup).length;
while(i < l)
{
basic = members[i++] as FlxBasic;
Please sign in to comment.
Something went wrong with that request. Please try again.