Better implementation of menu characters
This commit is contained in:
@ -3,18 +3,45 @@ package;
|
||||
import flixel.FlxSprite;
|
||||
import flixel.graphics.frames.FlxAtlasFrames;
|
||||
|
||||
class CharacterSetting
|
||||
{
|
||||
public var x(default, null):Int;
|
||||
public var y(default, null):Int;
|
||||
public var scale(default, null):Float;
|
||||
public var flipped(default, null):Bool;
|
||||
|
||||
public function new(x:Int = 0, y:Int = 0, scale:Float = 1.0, flipped:Bool = false)
|
||||
{
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.scale = scale;
|
||||
this.flipped = flipped;
|
||||
}
|
||||
}
|
||||
|
||||
class MenuCharacter extends FlxSprite
|
||||
{
|
||||
public var character:String;
|
||||
private static var settings:Map<String, CharacterSetting> = [
|
||||
'bf' => new CharacterSetting(0, -20, 1.0, true),
|
||||
'gf' => new CharacterSetting(50, 80, 1.5, true),
|
||||
'dad' => new CharacterSetting(-15, 130),
|
||||
'spooky' => new CharacterSetting(20, 30),
|
||||
'pico' => new CharacterSetting(0, 0, 1.0, true),
|
||||
'mom' => new CharacterSetting(-30, 140, 0.85),
|
||||
'parents-christmas' => new CharacterSetting(100, 130, 1.8),
|
||||
'senpai' => new CharacterSetting(-40, -45, 1.4)
|
||||
];
|
||||
|
||||
public function new(x:Float, character:String = 'bf')
|
||||
private var flipped:Bool = false;
|
||||
|
||||
public function new(x:Int, y:Int, scale:Float, flipped:Bool)
|
||||
{
|
||||
super(x);
|
||||
super(x, y);
|
||||
this.flipped = flipped;
|
||||
|
||||
this.character = character;
|
||||
antialiasing = true;
|
||||
|
||||
var tex = Paths.getSparrowAtlas('campaign_menu_UI_characters');
|
||||
frames = tex;
|
||||
frames = Paths.getSparrowAtlas('campaign_menu_UI_characters');
|
||||
|
||||
animation.addByPrefix('bf', "BF idle dance white", 24);
|
||||
animation.addByPrefix('bfConfirm', 'BF HEY!!', 24, false);
|
||||
@ -25,9 +52,28 @@ class MenuCharacter extends FlxSprite
|
||||
animation.addByPrefix('mom', "Mom Idle BLACK LINES", 24);
|
||||
animation.addByPrefix('parents-christmas', "Parent Christmas Idle", 24);
|
||||
animation.addByPrefix('senpai', "SENPAI idle Black Lines", 24);
|
||||
// Parent Christmas Idle
|
||||
|
||||
animation.play(character);
|
||||
setGraphicSize(Std.int(width * scale));
|
||||
updateHitbox();
|
||||
}
|
||||
|
||||
public function setCharacter(character:String):Void
|
||||
{
|
||||
if (character == '')
|
||||
{
|
||||
visible = false;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
visible = true;
|
||||
}
|
||||
|
||||
animation.play(character);
|
||||
|
||||
var setting:CharacterSetting = settings[character];
|
||||
offset.set(setting.x, setting.y);
|
||||
setGraphicSize(Std.int(width * setting.scale));
|
||||
flipX = setting.flipped != flipped;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user