mirror of
https://github.com/ninjamuffin99/Funkin.git
synced 2025-03-22 01:49:21 +00:00
offsets "generally"
This commit is contained in:
parent
c4fdb3295a
commit
5f939d3747
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 canHitText:FlxText;
|
||||||
|
|
||||||
private var dad:FlxSprite;
|
private var dad:FlxSprite;
|
||||||
private var boyfriend:FlxSprite;
|
private var boyfriend:Boyfriend;
|
||||||
|
|
||||||
private var notes:FlxTypedGroup<Note>;
|
private var notes:FlxTypedGroup<Note>;
|
||||||
|
|
||||||
|
@ -59,16 +59,7 @@ class PlayState extends FlxState
|
||||||
dad.animation.play('idle');
|
dad.animation.play('idle');
|
||||||
add(dad);
|
add(dad);
|
||||||
|
|
||||||
boyfriend = new FlxSprite(770, 450);
|
boyfriend = new Boyfriend(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');
|
|
||||||
add(boyfriend);
|
add(boyfriend);
|
||||||
|
|
||||||
strumLine = new FlxSprite(0, 50).makeGraphic(FlxG.width, 10);
|
strumLine = new FlxSprite(0, 50).makeGraphic(FlxG.width, 10);
|
||||||
|
@ -209,18 +200,22 @@ class PlayState extends FlxState
|
||||||
babyArrow.x += Note.swagWidth * 2;
|
babyArrow.x += Note.swagWidth * 2;
|
||||||
babyArrow.animation.addByPrefix('static', 'arrowUP');
|
babyArrow.animation.addByPrefix('static', 'arrowUP');
|
||||||
babyArrow.animation.addByPrefix('pressed', 'up press', 24, false);
|
babyArrow.animation.addByPrefix('pressed', 'up press', 24, false);
|
||||||
|
babyArrow.animation.addByPrefix('confirm', 'up confirm', 24, false);
|
||||||
case 2:
|
case 2:
|
||||||
babyArrow.x += Note.swagWidth * 3;
|
babyArrow.x += Note.swagWidth * 3;
|
||||||
babyArrow.animation.addByPrefix('static', 'arrowRIGHT');
|
babyArrow.animation.addByPrefix('static', 'arrowRIGHT');
|
||||||
babyArrow.animation.addByPrefix('pressed', 'right press', 24, false);
|
babyArrow.animation.addByPrefix('pressed', 'right press', 24, false);
|
||||||
|
babyArrow.animation.addByPrefix('confirm', 'right confirm', 24, false);
|
||||||
case 3:
|
case 3:
|
||||||
babyArrow.x += Note.swagWidth * 1;
|
babyArrow.x += Note.swagWidth * 1;
|
||||||
babyArrow.animation.addByPrefix('static', 'arrowDOWN');
|
babyArrow.animation.addByPrefix('static', 'arrowDOWN');
|
||||||
babyArrow.animation.addByPrefix('pressed', 'down press', 24, false);
|
babyArrow.animation.addByPrefix('pressed', 'down press', 24, false);
|
||||||
|
babyArrow.animation.addByPrefix('confirm', 'down confirm', 24, false);
|
||||||
case 4:
|
case 4:
|
||||||
babyArrow.x += Note.swagWidth * 0;
|
babyArrow.x += Note.swagWidth * 0;
|
||||||
babyArrow.animation.addByPrefix('static', 'arrowLEFT');
|
babyArrow.animation.addByPrefix('static', 'arrowLEFT');
|
||||||
babyArrow.animation.addByPrefix('pressed', 'left press', 24, false);
|
babyArrow.animation.addByPrefix('pressed', 'left press', 24, false);
|
||||||
|
babyArrow.animation.addByPrefix('confirm', 'left confirm', 24, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
babyArrow.animation.play('static');
|
babyArrow.animation.play('static');
|
||||||
|
@ -379,6 +374,15 @@ class PlayState extends FlxState
|
||||||
if (leftR)
|
if (leftR)
|
||||||
spr.animation.play('static');
|
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)
|
if (up || right || down || left)
|
||||||
|
@ -441,6 +445,14 @@ class PlayState extends FlxState
|
||||||
boyfriend.animation.play('singLEFT');
|
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;
|
sectionScores[1][curSection] += note.noteScore;
|
||||||
note.wasGoodHit = true;
|
note.wasGoodHit = true;
|
||||||
vocals.volume = 1;
|
vocals.volume = 1;
|
||||||
|
|
Loading…
Reference in a new issue