adding in cool text shit
This commit is contained in:
85
source/Alphabet.hx
Normal file
85
source/Alphabet.hx
Normal file
@ -0,0 +1,85 @@
|
||||
package;
|
||||
|
||||
import flixel.FlxSprite;
|
||||
import flixel.graphics.frames.FlxAtlasFrames;
|
||||
import flixel.group.FlxSpriteGroup;
|
||||
|
||||
using StringTools;
|
||||
|
||||
class Alphabet extends FlxSpriteGroup
|
||||
{
|
||||
// custom shit
|
||||
// amp, backslash, question mark, apostrophy, comma, angry faic, period
|
||||
var lastSprite:AlphaCharacter;
|
||||
|
||||
public function new(x:Float, y:Float, text:String = "", ?bold:Bool = false)
|
||||
{
|
||||
super(x, y);
|
||||
|
||||
var arrayShit:Array<String> = text.split("");
|
||||
trace(arrayShit);
|
||||
|
||||
var loopNum:Int = 0;
|
||||
|
||||
for (character in arrayShit)
|
||||
{
|
||||
if (character == " ")
|
||||
{
|
||||
}
|
||||
|
||||
if (AlphaCharacter.alphabet.contains(character.toLowerCase()))
|
||||
{
|
||||
var xPos:Float = 0;
|
||||
if (lastSprite != null)
|
||||
{
|
||||
xPos = lastSprite.x + lastSprite.frameWidth - 40;
|
||||
}
|
||||
|
||||
// var letter:AlphaCharacter = new AlphaCharacter(30 * loopNum, 0);
|
||||
var letter:AlphaCharacter = new AlphaCharacter(xPos, 0);
|
||||
letter.createBold(character);
|
||||
add(letter);
|
||||
|
||||
lastSprite = letter;
|
||||
}
|
||||
|
||||
loopNum += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class AlphaCharacter extends FlxSprite
|
||||
{
|
||||
public static var alphabet:String = "abcdefghijklmnopqrstuvwxyz";
|
||||
|
||||
var numbers:String = "1234567890";
|
||||
var symbols:String = "|~#$%()*+-:;<=>@[]^_";
|
||||
|
||||
public function new(x:Float, y:Float)
|
||||
{
|
||||
super(x, y);
|
||||
var tex = FlxAtlasFrames.fromSparrow(AssetPaths.alphabet__png, AssetPaths.alphabet__xml);
|
||||
frames = tex;
|
||||
|
||||
antialiasing = true;
|
||||
}
|
||||
|
||||
public function createBold(letter:String)
|
||||
{
|
||||
animation.addByPrefix(letter, letter.toUpperCase() + " bold", 24);
|
||||
animation.play(letter);
|
||||
updateHitbox();
|
||||
}
|
||||
|
||||
public function createLetter(letter:String):Void
|
||||
{
|
||||
var letterCase:String = "lowercase";
|
||||
if (letter.toLowerCase() != letter)
|
||||
{
|
||||
letterCase = 'capital';
|
||||
}
|
||||
|
||||
animation.addByPrefix(letter, letter + " " + letterCase, 24);
|
||||
animation.play(letter);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user