FlxControl

@link http://www.photonstorm.com

Static variables

Static methods

staticclear():Void

Removes all FlxControlHandlers. This is called automatically if this plugin is ever destroyed.

@:value({ EnableArrowKeys : true, UpdateFacing : false, Player : 1 })staticcreate(Sprite:FlxSprite, MovementType:Int, StoppingType:Int, Player:Int = 1, UpdateFacing:Bool = false, EnableArrowKeys:Bool = true):FlxControlHandler

Creates a new FlxControlHandler. You can have as many FlxControlHandlers as you like, but you usually only have one per player. The first handler you make will be assigned to the FlxControl.player1 var. The 2nd to FlxControl.player2 and so on for player3 and player4. Beyond this you need to keep a reference to the handler yourself.

Parameters:

Sprite

The FlxSprite you want this class to control. It can only control one FlxSprite at once.

MovementType

Set to either MOVEMENT_INSTANT or MOVEMENT_ACCELERATES

StoppingType

Set to STOPPING_INSTANT, STOPPING_DECELERATES or STOPPING_NEVER

Player

An optional ID for the player using these controls; using an ID of 1-4 will allow quick reference via FlxControl.player{ID}

UpdateFacing

If true it sets the FlxSprite.facing value to the direction pressed (default false)

EnableArrowKeys

If true it will enable all arrow keys (default) - see setCursorControl for more fine-grained control

Returns:

The new FlxControlHandler

staticremove(ControlHandler:FlxControlHandler):Bool

Removes a FlxControlHandler

Parameters:

ControlHandler

The FlxControlHandler to delete

Returns:

True if the FlxControlHandler was removed, otherwise false.

staticstart(?ControlHandler:FlxControlHandler):Void

Starts updating the given FlxControlHandler, enabling keyboard actions for it. If no FlxControlHandler is given it starts updating all FlxControlHandlers currently added. Updating is enabled by default, but this can be used to re-start it if you have stopped it via stop().

Parameters:

ControlHandler

The FlxControlHandler to start updating on. If left as null it will start updating all handlers.

staticstop(?ControlHandler:FlxControlHandler):Void

Stops updating the given FlxControlHandler. If no FlxControlHandler is given it stops updating all FlxControlHandlers currently added. Updating is enabled by default, but this can be used to stop it, for example if you paused your game (see start() to restart it again).

Parameters:

ControlHandler

The FlxControlHandler to stop updating. If left as null it will stop updating all handlers.

Constructor

new()

Methods

destroy():Void

Runs when this plugin is destroyed

update(elapsed:Float):Void

Runs update on all currently active FlxControlHandlers

Inherited Variables

Defined by FlxBasic

@:value(idEnumerator++)ID:Int = idEnumerator++

A unique ID starting from 0 and increasing by 1 for each subsequent FlxBasic that is created.

@:value(true)active:Bool = true

Controls whether update() is automatically called by FlxState/FlxGroup.

@:value(true)alive:Bool = true

Useful state for many game objects - "dead" (!alive) vs alive. kill() and revive() both flip this switch (along with exists, but you can override that).

camera:FlxCamera

Gets or sets the first camera of this object.

cameras:Array<FlxCamera>

This determines on which FlxCameras this object will be drawn. If it is null / has not been set, it uses the list of default draw targets, which is controlled via FlxG.camera.setDefaultDrawTarget as well as the DefaultDrawTarget argument of FlxG.camera.add.

@:value(true)exists:Bool = true

Controls whether update() and draw() are automatically called by FlxState/FlxGroup.

@:value(true)visible:Bool = true

Controls whether draw() is automatically called by FlxState/FlxGroup.

Inherited Methods

Defined by FlxBasic

draw():Void

Override this function to control how the object is drawn. Doing so is rarely necessary, but can be very useful.

kill():Void

Handy function for "killing" game objects. Use reset() to revive them. Default behavior is to flag them as nonexistent AND dead. However, if you want the "corpse" to remain in the game, like to animate an effect or whatever, you should override this, setting only alive to false, and leaving exists true.

revive():Void

Handy function for bringing game objects "back to life". Just sets alive and exists back to true. In practice, this function is most often called by FlxObject#reset().