FlxScrollingText -- Part of the Flixel Power Tools set -- Works only FLX_BLIT_RENDER mode for now

v1.0 First version released

@version 1.0 - May 5th 2011 @link http://www.photonstorm.com @co-author Ungar Djordje / ArtBIT (Haxe port)

Static methods

@:value({ loopOnWrap : true, onlyScrollOnscreen : true, text : null, steps : 0, pixels : 1 })staticadd(bitmapText:FlxBitmapText, region:Rectangle, pixels:Int = 1, steps:Int = 0, ?text:String, onlyScrollOnscreen:Bool = true, loopOnWrap:Bool = true):FlxSprite

Adds an FlxBitmapTextField to the Scrolling Text Manager and returns an FlxSprite which contains the text scroller in it. The FlxSprite will automatically update itself via this plugin, but can be treated as a normal FlxSprite in all other regards re: positioning, collision, rotation, etc.

Parameters:

bitmapText

A pre-prepared FlxBitmapTextField object (see the Test Suite examples for details on how this works)

region

A Rectangle that defines the size of the scrolling FlxSprite. The sprite will be placed at region.x/y and be region.width/height in size.

pixels

The number of pixels to scroll per step. For a smooth (but slow) scroll use low values. Keep the value proportional to the font width, so if the font width is 16 use a value like 1, 2, 4 or 8.

steps

How many steps should pass before the text is next scrolled? Default 0 means every step we scroll. Higher values slow things down.

text

The default text for your scrolling message. Can be changed in real-time via the addText method.

onlyScrollOnscreen

Only update the text scroller when this FlxSprite is visible on-screen? Default true.

loopOnWrap

When the scroller reaches the end of the given "text" should it wrap to the start? Default true. If false it will clear the screen then set itself to not update.

Returns:

An FlxSprite of size region.width/height, positioned at region.x/y, that auto-updates its contents while this plugin runs

@:value({ overwrite : false })staticaddText(source:FlxSprite, text:String, overwrite:Bool = false):Void

Adds or replaces the text in the given Text Scroller. Can be called while the scroller is still active.

Parameters:

source

The FlxSprite Text Scroller you wish to update (must have been added to FlxScrollingText via a call to add()

text

The text to add or update to the Scroller

overwrite

If true the given text will fully replace the previous scroller text. If false it will be appended to the end (default)

staticclear():Void

Removes all FlxSprites This is called automatically if the plugin is destroyed, but should be called manually by you if you change States as all the FlxSprites will be destroyed by Flixel otherwise

staticisScrolling(source:FlxSprite):Bool

Checks to see if the given FlxSprite is a Scrolling Text, and is actively scrolling or not Note: If the text is set to only scroll when on-screen, but if off-screen when this is called, it will still return true.

Parameters:

source

The FlxSprite to check for scrolling on.

Returns:

True if the FlxSprite was found and is scrolling, otherwise false

staticremove(source:FlxSprite):Bool

Removes an FlxSprite from the Text Scroller. Note that it doesn't restore the sprite bitmapData.

Parameters:

source

The FlxSprite to remove scrolling for.

Returns:

True if the FlxSprite was removed, otherwise false.

@:value({ source : null })staticstartScrolling(?source:FlxSprite):Void

Starts scrolling on the given FlxSprite. If no FlxSprite is given it starts scrolling on all FlxSprites currently added. Scrolling is enabled by default, but this can be used to re-start it if you have stopped it via stopScrolling.

Parameters:

source

The FlxSprite to start scrolling on. If left as null it will start scrolling on all sprites.

@:value({ source : null })staticstopScrolling(?source:FlxSprite):Void

Stops scrolling on the given FlxSprite. If no FlxSprite is given it stops scrolling on all FlxSprites currently added. Scrolling is enabled by default, but this can be used to stop it.

Parameters:

source

The FlxSprite to stop scrolling on. If left as null it will stop scrolling on all sprites.

Constructor

new()

Methods

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

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().

update(elapsed:Float):Void

Override this function to update your class's position and appearance. This is where most of your game rules and behavioral code will go.