Fork me on GitHub
View source

package haxepunk

class HXP

Static catch-all class used to access global properties and functions.

Static variables

View source

static read only VERSION : String

The HaxePunk version. Format: Major.Minor.Patch

static app : App

static assignedFrameRate : Float

The framerate assigned to the stage.

static bounds : Rectangle

A rectangle representing the size of the screen.

static read only camera : Camera

Point used to determine drawing offset in the render loop.

static read only choose : Dynamic

The choose function randomly chooses and returns one of the provided values.

static cursor : Cursor

View source

static defaultFont : String

The default font file to use, by default: font/monofonto.ttf.

static elapsed : Float

Game time elapsed since the last frame. For fixed framerate, this will be a constant 1/framerate.

static engine : Engine

The Engine instance.

static fixed : Bool

If the game is running at a fixed framerate.

View source

static focused : Bool

Whether the game has focus or not

View source

static frameRate : Float

The framerate assigned to the stage.

static fullscreen : Bool

Toggles between windowed and fullscreen modes

static read only halfHeight : Float

Half the screen height.

static read only halfWidth : Float

Half the screen width.

static height : Int

Height of the game.

View source

static needsResize : Bool

True if the scale of the screen has changed.

View source

static orientations : Array<Int>

Defines the allowed orientations

static pan : Float

Global panning factor for all sounds, a value from -1 to 1. Panning only applies to mono sounds. It is ignored on stereo.

View source

static rate : Float

Timescale applied to HXP.elapsed.

static renderingScene : Scene

If we're currently rendering, this is the Scene being rendered now.

static scene : Scene

The currently active Scene object. When you set this, the Scene is flagged to switch, but won't actually do so until the end of the current frame.

static screen : Screen

The Screen object, use to transform or offset the Screen.

static write only time : Float

View source

static tweener : Tweener

Global tweener for tweening between multiple scenes

View source

static volume : Float

Global volume factor for all sounds, a value from 0 to 1.

static width : Int

Width of the game.

View source

static windowHeight : Int

Height of the window.

View source

static windowWidth : Int

Width of the window.

Static functions

View source

static alarm (delay : Float, complete : Void ->Void, , type : TweenType, tweener : Tweener) : Alarm

Schedules a callback for the future. Shorthand for creating an Alarm tween, starting it and adding it to a Tweener.


Parameters:
delay   

The duration to wait before calling the callback.

complete   

The function to be called when complete.

type   

Tween type.

tweener   

The Tweener object to add this Alarm to. Defaults to HXP.tweener.


Returns:

The added Alarm object. Example: HXP.alarm(5.0, callbackFunction, TweenType.Looping); // Calls callbackFunction every 5 seconds

View source

static clear<T> (array : Array<T>) : Void

Empties an array of its' contents


Parameters:
array   

filled array

View source

static frames (from : Int, to : Int, skip : Int = 0) : Array<Int>

Gets an array of frame indices.


Parameters:
from   

Starting frame.

to   

Ending frame.

skip   

Skip amount every frame (eg. use 1 for every 2nd frame).


Returns:

The array.

View source

static indexOf<T> (arr : Array<T>, v : T) : Int

Optimized version of Lambda.indexOf for Array on dynamic platforms (Lambda.indexOf is less performant on those targets).


Parameters:
arr   

The array to look into.

param   

The value to look for.


Returns:

Returns the index of the first element [v] within Array [arr]. This function uses operator [==] to check for equality. If [v] does not exist in [arr], the result is -1.

View source

static insertSortedKey<T> (list : Array<T>, key : T, compare : T ->T ->Int, ) : Void

Binary insertion sort


Parameters:
list   

A list to insert into

key   

The key to insert

compare   

A comparison function to determine sort order

View source

static next<T> (current : T, options : Array<T>, loop : Bool = true) : T

Returns the next item after current in the list of options.


Parameters:
current   

The currently selected item (must be one of the options).

options   

An array of all the items to cycle through.

loop   

If true, will jump to the first item after the last item is reached.


Returns:

The next item in the list.

View source

static prev<T> (current : T, options : Array<T>, loop : Bool = true) : T

Returns the item previous to the current in the list of options.


Parameters:
current   

The currently selected item (must be one of the options).

options   

An array of all the items to cycle through.

loop   

If true, will jump to the last item after the first is reached.


Returns:

The previous item in the list.

View source

static resetCamera () : Void

Resets the camera position.

View source

static resize (width : Int, height : Int) : Void

Resize the screen.


Parameters:
width   

New width.

height   

New height.

View source

static setCamera (x : Float = 0, y : Float = 0) : Void

Sets the camera position.


Parameters:
x   

X position.

y   

Y position.

View source

static shuffle<T> (a : Array<T>) : Void

Shuffles the elements in the array.


Parameters:
a   

The Object to shuffle (an Array or Vector).

View source

static swap<T> (current : T, a : T, b : T) : T

Swaps the current item between a and b. Useful for quick state/string/value swapping.


Parameters:
current   

The currently selected item.

a   

Item a.

b   

Item b.


Returns:

Returns a if current is b, and b if current is a.

View source

static timeFlag () : Float

Sets a time flag.


Returns:

Time elapsed (in milliseconds) since the last time flag was set.

View source

static tween (object : Dynamic, values : Dynamic, duration : Float, ?options : Dynamic) : MultiVarTween

Tweens numeric public properties of an Object. Shorthand for creating a MultiVarTween tween, starting it and adding it to a Tweener.


Parameters:
object   

The object containing the properties to tween.

values   

An object containing key/value pairs of properties and target values.

duration   

Duration of the tween.

options   

An object containing key/value pairs of the following optional parameters: type Tween type. complete Optional completion callback function. ease Optional easer function. tweener The Tweener to add this Tween to.


Returns:

The added MultiVarTween object. Example: HXP.tween(object, { x: 500, y: 350 }, 2.0, { ease: Float -> Float, complete: onComplete } );