Created
November 4, 2014 18:22
-
-
Save 01010111/1f163be5a4ed225bf20f to your computer and use it in GitHub Desktop.
Updated FlxText Centering Stack Overflow
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package; | |
import flixel.FlxG; | |
import flixel.FlxState; | |
import flixel.text.FlxText; | |
import flixel.text.FlxText.FlxTextAlign; | |
class MenuState extends FlxState | |
{ | |
var centeredText:FlxText; | |
var textCounter:Int = 0; | |
override public function create():Void | |
{ | |
centeredText = new FlxText(0, FlxG.height * 0.4, FlxG.width); | |
centeredText.setFormat(null, 16, 0xffffff, FlxTextAlign.CENTER); | |
add(centeredText); | |
centeredText.text = "" + textCounter; | |
super.create(); | |
} | |
override public function update(elapsed:Float):Void | |
{ | |
textCounter++; | |
centeredText.text = "" + textCounter; | |
super.update(elapsed); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment