mirror of
https://github.com/ninjamuffin99/Funkin.git
synced 2024-12-27 07:27:12 +00:00
offsets "generally"
This commit is contained in:
parent
86aba3f004
commit
89fa9a3121
51
source/Boyfriend.hx
Normal file
51
source/Boyfriend.hx
Normal file
|
@ -0,0 +1,51 @@
|
|||
package;
|
||||
|
||||
import flixel.FlxG;
|
||||
import flixel.FlxSprite;
|
||||
import flixel.graphics.frames.FlxAtlasFrames;
|
||||
|
||||
class Boyfriend extends FlxSprite
|
||||
{
|
||||
private var animOffsets:Map<String, Array<Dynamic>>;
|
||||
|
||||
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);
|
||||
animation.play('idle');
|
||||
|
||||
addOffset("singUP", -25, 35);
|
||||
addOffset("singRIGHT", -40, -8);
|
||||
addOffset("singLEFT", 0, 0);
|
||||
addOffset("singDOWN", 0, -45);
|
||||
addOffset("hey", 0, -0);
|
||||
}
|
||||
|
||||
override function update(elapsed:Float)
|
||||
{
|
||||
super.update(elapsed);
|
||||
|
||||
var daOffset = animOffsets.get(animation.curAnim.name);
|
||||
|
||||
if (animOffsets.exists(animation.curAnim.name))
|
||||
{
|
||||
offset.set(daOffset[0], daOffset[1]);
|
||||
}
|
||||
else
|
||||
centerOffsets();
|
||||
}
|
||||
|
||||
public function addOffset(name:String, x:Float = 0, y:Float = 0)
|
||||
{
|
||||
animOffsets[name] = [x, y];
|
||||
}
|
||||
}
|
|
@ -33,7 +33,7 @@ class PlayState extends FlxState
|
|||
private var canHitText:FlxText;
|
||||
|
||||
private var dad:FlxSprite;
|
||||
private var boyfriend:FlxSprite;
|
||||
private var boyfriend:Boyfriend;
|
||||
|
||||
private var notes:FlxTypedGroup<Note>;
|
||||
|
||||
|
@ -59,16 +59,7 @@ class PlayState extends FlxState
|
|||
dad.animation.play('idle');
|
||||
add(dad);
|
||||
|
||||
boyfriend = new FlxSprite(770, 450);
|
||||
var tex = FlxAtlasFrames.fromSparrow(AssetPaths.BOYFRIEND__png, AssetPaths.BOYFRIEND__xml);
|
||||
boyfriend.frames = tex;
|
||||
boyfriend.animation.addByPrefix('idle', 'BF idle dance', 24, false);
|
||||
boyfriend.animation.addByPrefix('singUP', 'BF NOTE UP', 24, false);
|
||||
boyfriend.animation.addByPrefix('singLEFT', 'BF NOTE LEFT', 24, false);
|
||||
boyfriend.animation.addByPrefix('singRIGHT', 'BF NOTE RIGHT', 24, false);
|
||||
boyfriend.animation.addByPrefix('singDOWN', 'BF NOTE DOWN', 24, false);
|
||||
boyfriend.animation.addByPrefix('hey', 'BF HEY', 24, false);
|
||||
boyfriend.animation.play('idle');
|
||||
boyfriend = new Boyfriend(770, 450);
|
||||
add(boyfriend);
|
||||
|
||||
strumLine = new FlxSprite(0, 50).makeGraphic(FlxG.width, 10);
|
||||
|
@ -209,18 +200,22 @@ class PlayState extends FlxState
|
|||
babyArrow.x += Note.swagWidth * 2;
|
||||
babyArrow.animation.addByPrefix('static', 'arrowUP');
|
||||
babyArrow.animation.addByPrefix('pressed', 'up press', 24, false);
|
||||
babyArrow.animation.addByPrefix('confirm', 'up confirm', 24, false);
|
||||
case 2:
|
||||
babyArrow.x += Note.swagWidth * 3;
|
||||
babyArrow.animation.addByPrefix('static', 'arrowRIGHT');
|
||||
babyArrow.animation.addByPrefix('pressed', 'right press', 24, false);
|
||||
babyArrow.animation.addByPrefix('confirm', 'right confirm', 24, false);
|
||||
case 3:
|
||||
babyArrow.x += Note.swagWidth * 1;
|
||||
babyArrow.animation.addByPrefix('static', 'arrowDOWN');
|
||||
babyArrow.animation.addByPrefix('pressed', 'down press', 24, false);
|
||||
babyArrow.animation.addByPrefix('confirm', 'down confirm', 24, false);
|
||||
case 4:
|
||||
babyArrow.x += Note.swagWidth * 0;
|
||||
babyArrow.animation.addByPrefix('static', 'arrowLEFT');
|
||||
babyArrow.animation.addByPrefix('pressed', 'left press', 24, false);
|
||||
babyArrow.animation.addByPrefix('confirm', 'left confirm', 24, false);
|
||||
}
|
||||
|
||||
babyArrow.animation.play('static');
|
||||
|
@ -379,6 +374,15 @@ class PlayState extends FlxState
|
|||
if (leftR)
|
||||
spr.animation.play('static');
|
||||
}
|
||||
|
||||
if (spr.animation.curAnim.name == 'confirm')
|
||||
{
|
||||
spr.centerOffsets();
|
||||
spr.offset.x -= 13;
|
||||
spr.offset.y -= 13;
|
||||
}
|
||||
else
|
||||
spr.centerOffsets();
|
||||
});
|
||||
|
||||
if (up || right || down || left)
|
||||
|
@ -441,6 +445,14 @@ class PlayState extends FlxState
|
|||
boyfriend.animation.play('singLEFT');
|
||||
}
|
||||
|
||||
playerStrums.forEach(function(spr:FlxSprite)
|
||||
{
|
||||
if (Math.abs(note.noteData) == spr.ID)
|
||||
{
|
||||
spr.animation.play('confirm', true);
|
||||
}
|
||||
});
|
||||
|
||||
sectionScores[1][curSection] += note.noteScore;
|
||||
note.wasGoodHit = true;
|
||||
vocals.volume = 1;
|
||||
|
|
Loading…
Reference in a new issue