Packageorg.flixel
Classpublic class FlxU
InheritanceFlxU Inheritance Object



Public Properties
 PropertyDefined By
  quadTree : FlxQuadTree
[static] The global quad tree (stored here since it is used primarily by FlxU functions).
FlxU
  quadTreeBounds : FlxRect
[static] This variable stores the dimensions of the root of the quad tree.
FlxU
  quadTreeDivisions : uint = 3
[static] Controls the granularity of the quad tree.
FlxU
  roundingError : Number = 0.0000001
[static] Helps to eliminate false collisions and/or rendering glitches caused by rounding errors
FlxU
  seed : Number
[static] Set seed to a number between 0 and 1 if you want FlxG.random() to generate a predictable series of numbers.
FlxU
Protected Properties
 PropertyDefined By
  _originalSeed : Number
[static] Internal random number calculation helpers.
FlxU
  _seed : Number
[static] Internal random number calculation helpers.
FlxU
Public Methods
 MethodDefined By
  
abs(N:Number):Number
[static]
FlxU
  
ceil(N:Number):Number
[static]
FlxU
  
collide(Object1:FlxObject, Object2:FlxObject):Boolean
[static] Call this function to see if one FlxObject collides with another.
FlxU
  
computeVelocity(Velocity:Number, Acceleration:Number = 0, Drag:Number = 0, Max:Number = 10000):Number
[static] A tween-like function that takes a starting velocity and some other factors and returns an altered velocity.
FlxU
  
endProfile(Start:uint, Name:String = Profiler, Log:Boolean = true):uint
[static] Useful for finding out how long it takes to execute specific blocks of code.
FlxU
  
floor(N:Number):Number
[static]
FlxU
  
getAngle(X:Number, Y:Number):Number
[static] Calculates the angle between a point and the origin (0,0).
FlxU
  
getClass(Name:String):Class
[static] Look up a Class object by its string name.
FlxU
  
getClassName(Obj:Object, Simple:Boolean = false):String
[static] Get the String name of any Object.
FlxU
  
mutate(Seed:Number, Mutator:Number):Number
[static] Mutates a seed or other number, useful when combined with randomize().
FlxU
  
openURL(URL:String):void
[static] Opens a web page in a new tab or window.
FlxU
  
overlap(Object1:FlxObject, Object2:FlxObject, Callback:Function = null):Boolean
[static] Call this function to see if one FlxObject overlaps another.
FlxU
  
random(UseGlobalSeed:Boolean = true):Number
[static] Generate a pseudo-random number.
FlxU
  
randomize(Seed:Number):Number
[static] Generate a pseudo-random number.
FlxU
  
rotatePoint(X:Number, Y:Number, PivotX:Number, PivotY:Number, Angle:Number, P:FlxPoint = null):FlxPoint
[static] Rotates a point in 2D space around another point by the given angle.
FlxU
  
setWorldBounds(X:Number = 0, Y:Number = 0, Width:Number = 0, Height:Number = 0, Divisions:uint = 3):void
[static] Call this function to specify a more efficient boundary for your game world.
FlxU
  
solveXCollision(Object1:FlxObject, Object2:FlxObject):Boolean
[static] This quad tree callback function can be used externally as well.
FlxU
  
solveYCollision(Object1:FlxObject, Object2:FlxObject):Boolean
[static] This quad tree callback function can be used externally as well.
FlxU
  
[static] Useful for finding out how long it takes to execute specific blocks of code.
FlxU
Property Detail
_originalSeedproperty
protected static var _originalSeed:Number

Internal random number calculation helpers.

_seedproperty 
protected static var _seed:Number

Internal random number calculation helpers.

quadTreeproperty 
public static var quadTree:FlxQuadTree

The global quad tree (stored here since it is used primarily by FlxU functions). Set this to null to force it to refresh on the next collide.

quadTreeBoundsproperty 
public static var quadTreeBounds:FlxRect

This variable stores the dimensions of the root of the quad tree. This is the eligible game collision space.

quadTreeDivisionsproperty 
public static var quadTreeDivisions:uint = 3

Controls the granularity of the quad tree. Default is 3 (decent performance on large and small worlds).

roundingErrorproperty 
public static var roundingError:Number = 0.0000001

Helps to eliminate false collisions and/or rendering glitches caused by rounding errors

seedproperty 
seed:Number

Set seed to a number between 0 and 1 if you want FlxG.random() to generate a predictable series of numbers. NOTE: reading the seed will return the original value passed in, not the current mutation.


Implementation
    public static function get seed():Number
    public static function set seed(value:Number):void
Method Detail
abs()method
public static function abs(N:Number):Number

Parameters

N:Number

Returns
Number
ceil()method 
public static function ceil(N:Number):Number

Parameters

N:Number

Returns
Number
collide()method 
public static function collide(Object1:FlxObject, Object2:FlxObject):Boolean

Call this function to see if one FlxObject collides with another. Can be called with one object and one group, or two groups, or two objects, whatever floats your boat! It will put everything into a quad tree and then check for collisions. For maximum performance try bundling a lot of objects together using a FlxGroup (even bundling groups together!) NOTE: does NOT take objects' scrollfactor into account.

Parameters

Object1:FlxObject — The first object or group you want to check.
 
Object2:FlxObject — The second object or group you want to check. If it is the same as the first, flixel knows to just do a comparison within that group.

Returns
Boolean
computeVelocity()method 
public static function computeVelocity(Velocity:Number, Acceleration:Number = 0, Drag:Number = 0, Max:Number = 10000):Number

A tween-like function that takes a starting velocity and some other factors and returns an altered velocity.

Parameters

Velocity:Number — Any component of velocity (e.g. 20).
 
Acceleration:Number (default = 0) — Rate at which the velocity is changing.
 
Drag:Number (default = 0) — Really kind of a deceleration, this is how much the velocity changes if Acceleration is not set.
 
Max:Number (default = 10000) — An absolute value cap for the velocity.

Returns
Number — The altered Velocity value.
endProfile()method 
public static function endProfile(Start:uint, Name:String = Profiler, Log:Boolean = true):uint

Useful for finding out how long it takes to execute specific blocks of code.

Parameters

Start:uint — A uint created by FlxU.startProfile().
 
Name:String (default = Profiler) — Optional tag (for debug console display). Default value is "Profiler".
 
Log:Boolean (default = true) — Whether or not to log this elapsed time in the debug console.

Returns
uint — A uint to be passed to FlxU.endProfile().
floor()method 
public static function floor(N:Number):Number

Parameters

N:Number

Returns
Number
getAngle()method 
public static function getAngle(X:Number, Y:Number):Number

Calculates the angle between a point and the origin (0,0).

Parameters

X:Number — The X coordinate of the point.
 
Y:Number — The Y coordinate of the point.

Returns
Number — The angle in degrees.
getClass()method 
public static function getClass(Name:String):Class

Look up a Class object by its string name.

Parameters

Name:String — The String name of the Class you are interested in.

Returns
Class — A Class object.
getClassName()method 
public static function getClassName(Obj:Object, Simple:Boolean = false):String

Get the String name of any Object.

Parameters

Obj:Object — The Object object in question.
 
Simple:Boolean (default = false) — Returns only the class name, not the package or packages.

Returns
String — The name of the Class as a String object.
mutate()method 
public static function mutate(Seed:Number, Mutator:Number):Number

Mutates a seed or other number, useful when combined with randomize().

Parameters

Seed:Number — The number to mutate.
 
Mutator:Number — The value to use in the mutation.

Returns
Number — A predictably-altered version of the Seed.
openURL()method 
public static function openURL(URL:String):void

Opens a web page in a new tab or window.

Parameters

URL:String — The address of the web page.

overlap()method 
public static function overlap(Object1:FlxObject, Object2:FlxObject, Callback:Function = null):Boolean

Call this function to see if one FlxObject overlaps another. Can be called with one object and one group, or two groups, or two objects, whatever floats your boat! It will put everything into a quad tree and then check for overlaps. For maximum performance try bundling a lot of objects together using a FlxGroup (even bundling groups together!) NOTE: does NOT take objects' scrollfactor into account.

Parameters

Object1:FlxObject — The first object or group you want to check.
 
Object2:FlxObject — The second object or group you want to check. If it is the same as the first, flixel knows to just do a comparison within that group.
 
Callback:Function (default = null) — A function with two FlxObject parameters - e.g. myOverlapFunction(Object1:FlxObject,Object2:FlxObject); If no function is provided, FlxQuadTree will call kill() on both objects.

Returns
Boolean
random()method 
public static function random(UseGlobalSeed:Boolean = true):Number

Generate a pseudo-random number.

Parameters

UseGlobalSeed:Boolean (default = true) — Whether or not to use the stored FlxG.seed value to calculate it.

Returns
Number — A pseudo-random Number object.
randomize()method 
public static function randomize(Seed:Number):Number

Generate a pseudo-random number.

Parameters

Seed:Number — The number to use to generate a new random value.

Returns
Number — A pseudo-random Number object.
rotatePoint()method 
public static function rotatePoint(X:Number, Y:Number, PivotX:Number, PivotY:Number, Angle:Number, P:FlxPoint = null):FlxPoint

Rotates a point in 2D space around another point by the given angle.

Parameters

X:Number — The X coordinate of the point you want to rotate.
 
Y:Number — The Y coordinate of the point you want to rotate.
 
PivotX:Number — The X coordinate of the point you want to rotate around.
 
PivotY:Number — The Y coordinate of the point you want to rotate around.
 
Angle:Number — Rotate the point by this many degrees.
 
P:FlxPoint (default = null) — Optional FlxPoint to store the results in.

Returns
FlxPoint — A FlxPoint containing the coordinates of the rotated point.
setWorldBounds()method 
public static function setWorldBounds(X:Number = 0, Y:Number = 0, Width:Number = 0, Height:Number = 0, Divisions:uint = 3):void

Call this function to specify a more efficient boundary for your game world. This boundary is used by overlap() and collide(), so it can't hurt to have it be the right size! Flixel will invent a size for you, but it's pretty huge - 256x the size of the screen, whatever that may be. Leave width and height empty if you want to just update the game world's position.

Parameters

X:Number (default = 0) — The X-coordinate of the left side of the game world.
 
Y:Number (default = 0) — The Y-coordinate of the top of the game world.
 
Width:Number (default = 0) — Desired width of the game world.
 
Height:Number (default = 0) — Desired height of the game world.
 
Divisions:uint (default = 3) — Pass a non-zero value to set quadTreeDivisions. Default value is 3.

solveXCollision()method 
public static function solveXCollision(Object1:FlxObject, Object2:FlxObject):Boolean

This quad tree callback function can be used externally as well. Takes two objects and separates them along their X axis (if possible/reasonable).

Parameters

Object1:FlxObject — The first object or group you want to check.
 
Object2:FlxObject — The second object or group you want to check.

Returns
Boolean
solveYCollision()method 
public static function solveYCollision(Object1:FlxObject, Object2:FlxObject):Boolean

This quad tree callback function can be used externally as well. Takes two objects and separates them along their Y axis (if possible/reasonable).

Parameters

Object1:FlxObject — The first object or group you want to check.
 
Object2:FlxObject — The second object or group you want to check.

Returns
Boolean
startProfile()method 
public static function startProfile():uint

Useful for finding out how long it takes to execute specific blocks of code.

Returns
uint — A uint to be passed to FlxU.endProfile().