2020-10-25 16:51:06 -04:00
|
|
|
package;
|
|
|
|
|
2020-10-26 05:16:05 -04:00
|
|
|
import flixel.FlxG;
|
2020-10-25 16:51:06 -04:00
|
|
|
import flixel.FlxSprite;
|
|
|
|
import flixel.graphics.frames.FlxAtlasFrames;
|
|
|
|
import flixel.group.FlxSpriteGroup;
|
2020-10-26 05:16:05 -04:00
|
|
|
import flixel.math.FlxMath;
|
|
|
|
import flixel.util.FlxTimer;
|
2020-10-25 16:51:06 -04:00
|
|
|
|
|
|
|
using StringTools;
|
|
|
|
|
2020-10-25 17:38:48 -04:00
|
|
|
/**
|
|
|
|
* Loosley based on FlxTypeText lolol
|
|
|
|
*/
|
2020-10-25 16:51:06 -04:00
|
|
|
class Alphabet extends FlxSpriteGroup
|
|
|
|
{
|
2020-10-25 17:38:48 -04:00
|
|
|
public var delay:Float = 0.05;
|
|
|
|
public var paused:Bool = false;
|
|
|
|
|
|
|
|
var _finalText:String = "";
|
|
|
|
var _curText:String = "";
|
|
|
|
|
2020-10-26 05:16:05 -04:00
|
|
|
public var widthOfWords:Float = FlxG.width;
|
|
|
|
|
|
|
|
var yMulti:Float = 1;
|
|
|
|
|
2020-10-25 16:51:06 -04:00
|
|
|
// custom shit
|
|
|
|
// amp, backslash, question mark, apostrophy, comma, angry faic, period
|
|
|
|
var lastSprite:AlphaCharacter;
|
2020-10-26 05:16:05 -04:00
|
|
|
var xPosResetted:Bool = false;
|
2020-10-25 16:51:06 -04:00
|
|
|
|
|
|
|
public function new(x:Float, y:Float, text:String = "", ?bold:Bool = false)
|
|
|
|
{
|
|
|
|
super(x, y);
|
|
|
|
|
2020-10-25 17:38:48 -04:00
|
|
|
_finalText = text;
|
|
|
|
|
2020-10-25 16:51:06 -04:00
|
|
|
var arrayShit:Array<String> = text.split("");
|
|
|
|
trace(arrayShit);
|
|
|
|
|
|
|
|
var loopNum:Int = 0;
|
|
|
|
|
2020-10-26 05:16:05 -04:00
|
|
|
new FlxTimer().start(0.05, function(tmr:FlxTimer)
|
2020-10-25 16:51:06 -04:00
|
|
|
{
|
2020-10-26 05:16:05 -04:00
|
|
|
var xPos:Float = 0;
|
|
|
|
|
|
|
|
// trace(_finalText.fastCodeAt(loopNum) + " " + _finalText.charAt(loopNum));
|
|
|
|
if (_finalText.fastCodeAt(loopNum) == "\n".code)
|
2020-10-25 16:51:06 -04:00
|
|
|
{
|
2020-10-26 05:16:05 -04:00
|
|
|
yMulti += 1;
|
|
|
|
xPosResetted = true;
|
|
|
|
// xPos = 0;
|
2020-10-25 16:51:06 -04:00
|
|
|
}
|
|
|
|
|
2020-10-26 05:16:05 -04:00
|
|
|
if (AlphaCharacter.alphabet.contains(arrayShit[loopNum].toLowerCase()))
|
2020-10-25 16:51:06 -04:00
|
|
|
{
|
2020-10-26 05:16:05 -04:00
|
|
|
if (lastSprite != null && !xPosResetted)
|
2020-10-25 16:51:06 -04:00
|
|
|
{
|
|
|
|
xPos = lastSprite.x + lastSprite.frameWidth - 40;
|
|
|
|
}
|
2020-10-26 05:16:05 -04:00
|
|
|
else
|
|
|
|
{
|
|
|
|
xPosResetted = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// trace(_finalText.fastCodeAt(loopNum) + " " + _finalText.charAt(loopNum));
|
2020-10-25 16:51:06 -04:00
|
|
|
|
|
|
|
// var letter:AlphaCharacter = new AlphaCharacter(30 * loopNum, 0);
|
2020-10-26 05:16:05 -04:00
|
|
|
var letter:AlphaCharacter = new AlphaCharacter(xPos, 55 * yMulti);
|
|
|
|
letter.createBold(arrayShit[loopNum]);
|
2020-10-25 16:51:06 -04:00
|
|
|
add(letter);
|
|
|
|
|
|
|
|
lastSprite = letter;
|
|
|
|
}
|
|
|
|
|
|
|
|
loopNum += 1;
|
2020-10-26 05:16:05 -04:00
|
|
|
|
|
|
|
tmr.time = FlxG.random.float(0.03, 0.09);
|
|
|
|
}, arrayShit.length);
|
|
|
|
|
|
|
|
for (character in arrayShit)
|
|
|
|
{
|
|
|
|
// if (character.fastCodeAt() == " ")
|
|
|
|
// {
|
|
|
|
// }
|
|
|
|
|
|
|
|
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;
|
2020-10-25 16:51:06 -04:00
|
|
|
}
|
|
|
|
}
|
2020-10-25 17:38:48 -04:00
|
|
|
|
|
|
|
override function update(elapsed:Float)
|
|
|
|
{
|
|
|
|
super.update(elapsed);
|
|
|
|
}
|
2020-10-25 16:51:06 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|