2020-10-04 18:50:12 +00:00
|
|
|
package;
|
|
|
|
|
|
|
|
import flixel.FlxG;
|
|
|
|
import flixel.FlxSprite;
|
|
|
|
import flixel.graphics.frames.FlxAtlasFrames;
|
|
|
|
|
|
|
|
class Boyfriend extends FlxSprite
|
|
|
|
{
|
2020-10-04 21:44:52 +00:00
|
|
|
public var animOffsets:Map<String, Array<Dynamic>>;
|
|
|
|
|
|
|
|
public var debugMode:Bool = false;
|
2020-10-04 18:50:12 +00:00
|
|
|
|
|
|
|
public function new(x:Float, y:Float)
|
|
|
|
{
|
|
|
|
super(x, y);
|
|
|
|
animOffsets = new Map<String, Array<Dynamic>>();
|
|
|
|
|
|
|
|
var tex = FlxAtlasFrames.fromSparrow(AssetPaths.BOYFRIEND__png, AssetPaths.BOYFRIEND__xml);
|
|
|
|
frames = tex;
|
|
|
|
animation.addByPrefix('idle', 'BF idle dance', 24, false);
|
|
|
|
animation.addByPrefix('singUP', 'BF NOTE UP', 24, false);
|
|
|
|
animation.addByPrefix('singLEFT', 'BF NOTE LEFT', 24, false);
|
|
|
|
animation.addByPrefix('singRIGHT', 'BF NOTE RIGHT', 24, false);
|
|
|
|
animation.addByPrefix('singDOWN', 'BF NOTE DOWN', 24, false);
|
|
|
|
animation.addByPrefix('hey', 'BF HEY', 24, false);
|
2020-10-04 21:44:52 +00:00
|
|
|
playAnim('idle');
|
|
|
|
|
|
|
|
addOffset('idle');
|
|
|
|
addOffset("singUP", -28, 27);
|
|
|
|
addOffset("singRIGHT", -38, -7);
|
|
|
|
addOffset("singLEFT", 12, -6);
|
|
|
|
addOffset("singDOWN", -14, -50);
|
|
|
|
addOffset("hey", 1, 6);
|
2020-10-04 18:50:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
override function update(elapsed:Float)
|
|
|
|
{
|
|
|
|
super.update(elapsed);
|
2020-10-04 21:44:52 +00:00
|
|
|
}
|
2020-10-04 18:50:12 +00:00
|
|
|
|
2020-10-04 21:44:52 +00:00
|
|
|
public function playAnim(AnimName:String, Force:Bool = false, Reversed:Bool = false, Frame:Int = 0):Void
|
|
|
|
{
|
|
|
|
animation.play(AnimName, Force, Reversed, Frame);
|
2020-10-04 18:50:12 +00:00
|
|
|
|
2020-10-04 21:44:52 +00:00
|
|
|
var daOffset = animOffsets.get(animation.curAnim.name);
|
2020-10-04 18:50:12 +00:00
|
|
|
if (animOffsets.exists(animation.curAnim.name))
|
|
|
|
{
|
|
|
|
offset.set(daOffset[0], daOffset[1]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function addOffset(name:String, x:Float = 0, y:Float = 0)
|
|
|
|
{
|
|
|
|
animOffsets[name] = [x, y];
|
|
|
|
}
|
|
|
|
}
|