mirror of
https://github.com/ninjamuffin99/Funkin.git
synced 2025-03-22 18:09:33 +00:00
Fixes for the atlasSprite bizz
This commit is contained in:
parent
0b19b4bc25
commit
353aa42f5b
2
assets
2
assets
|
@ -1 +1 @@
|
|||
Subproject commit 0e4392bcb0ed1dbb496764cff074635c20c91389
|
||||
Subproject commit f986e52819c5fd2e47f4d8d3297f326351682675
|
|
@ -9,6 +9,7 @@ import flixel.system.FlxAssets.FlxGraphicAsset;
|
|||
import openfl.display.BitmapData;
|
||||
import openfl.utils.Assets;
|
||||
import flixel.math.FlxPoint;
|
||||
import flxanimate.animate.FlxKeyFrame;
|
||||
|
||||
/**
|
||||
* A sprite which provides convenience functions for rendering a texture atlas with animations.
|
||||
|
@ -121,6 +122,12 @@ class FlxAtlasSprite extends FlxAnimate
|
|||
return false;
|
||||
}
|
||||
|
||||
var _completeAnim:Bool = false;
|
||||
|
||||
var fr:FlxKeyFrame = null;
|
||||
|
||||
var looping:Bool = false;
|
||||
|
||||
/**
|
||||
* Plays an animation.
|
||||
* @param id A string ID of the animation to play.
|
||||
|
@ -174,6 +181,8 @@ class FlxAtlasSprite extends FlxAnimate
|
|||
}
|
||||
});
|
||||
|
||||
looping = loop;
|
||||
|
||||
// Prevent other animations from playing if `ignoreOther` is true.
|
||||
if (ignoreOther) canPlayOtherAnims = false;
|
||||
|
||||
|
@ -182,6 +191,9 @@ class FlxAtlasSprite extends FlxAnimate
|
|||
trace('Playing animation $id');
|
||||
this.anim.play(id, restart, false, startFrame);
|
||||
goToFrameLabel(id);
|
||||
|
||||
fr = anim.getFrameLabel(id);
|
||||
|
||||
anim.curFrame += startFrame;
|
||||
this.currentAnimation = id;
|
||||
}
|
||||
|
@ -259,7 +271,21 @@ class FlxAtlasSprite extends FlxAnimate
|
|||
if (currentAnimation != null)
|
||||
{
|
||||
onAnimationFrame.dispatch(currentAnimation, frame);
|
||||
if (isLoopComplete()) onAnimationLoopComplete.dispatch(currentAnimation);
|
||||
|
||||
if (fr != null && frame > (fr.index + fr.duration - 1) || isLoopFinished())
|
||||
{
|
||||
anim.pause();
|
||||
_onAnimationComplete();
|
||||
if (looping)
|
||||
{
|
||||
anim.curFrame = (fr != null) ? fr.index : 0;
|
||||
anim.resume();
|
||||
}
|
||||
else
|
||||
{
|
||||
anim.curFrame--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -267,7 +293,9 @@ class FlxAtlasSprite extends FlxAnimate
|
|||
{
|
||||
if (currentAnimation != null)
|
||||
{
|
||||
onAnimationComplete.dispatch(currentAnimation);
|
||||
if (looping) onAnimationLoopComplete.dispatch(currentAnimation);
|
||||
else
|
||||
onAnimationComplete.dispatch(currentAnimation);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -29,39 +29,12 @@ class CharSelectGF extends FlxAtlasSprite
|
|||
public function new()
|
||||
{
|
||||
super(0, 0, Paths.animateAtlas("charSelect/gfChill"));
|
||||
anim.play("");
|
||||
|
||||
list = anim.curSymbol.getFrameLabelNames();
|
||||
|
||||
switchGF("bf");
|
||||
}
|
||||
|
||||
var _addedCallback:String = "";
|
||||
|
||||
override public function playAnimation(id:String, restart:Bool = false, ignoreOther:Bool = false, loop:Bool = false, startFrame:Int = 0):Void
|
||||
{
|
||||
if (id == null) id = "idle";
|
||||
// var fr = anim.getFrameLabel("confirm");
|
||||
// fr.removeCallbacks();
|
||||
// fr.add(() -> trace("HEY"));
|
||||
|
||||
if (id != _addedCallback)
|
||||
{
|
||||
var next = list[list.indexOf(_addedCallback) + 1];
|
||||
if (next != null) anim.getFrameLabel(next).removeCallbacks();
|
||||
|
||||
var index:Int = list.indexOf(id);
|
||||
|
||||
_addedCallback = list[index];
|
||||
if (index != -1 && index + 1 < list.length)
|
||||
{
|
||||
var lb = anim.getFrameLabel(list[index + 1]);
|
||||
@:privateAccess
|
||||
lb.add(() -> playAnimation(list[index], true, false, false));
|
||||
}
|
||||
}
|
||||
super.playAnimation(id, restart, ignoreOther, loop, startFrame);
|
||||
}
|
||||
|
||||
override public function update(elapsed:Float)
|
||||
{
|
||||
super.update(elapsed);
|
||||
|
@ -190,9 +163,8 @@ class CharSelectGF extends FlxAtlasSprite
|
|||
animInInfo = FramesJSFLParser.parse(Paths.file("images/charSelect/" + str + "AnimInfo/" + str + "In.txt"));
|
||||
animOutInfo = FramesJSFLParser.parse(Paths.file("images/charSelect/" + str + "AnimInfo/" + str + "Out.txt"));
|
||||
|
||||
anim.play("");
|
||||
playAnimation("idle", true, false, false);
|
||||
addFrameCallback(getNextFrameLabel("idle"), () -> playAnimation("idle", true, false, false));
|
||||
playAnimation("idle", true, false, true);
|
||||
// addFrameCallback(getNextFrameLabel("idle"), () -> playAnimation("idle", true, false, false));
|
||||
|
||||
updateHitbox();
|
||||
}
|
||||
|
|
|
@ -2,82 +2,33 @@ package funkin.ui.charSelect;
|
|||
|
||||
import flixel.FlxSprite;
|
||||
import funkin.graphics.adobeanimate.FlxAtlasSprite;
|
||||
import flxanimate.animate.FlxKeyFrame;
|
||||
|
||||
class CharSelectPlayer extends FlxAtlasSprite
|
||||
{
|
||||
var desLp:FlxKeyFrame = null;
|
||||
|
||||
public function new(x:Float, y:Float)
|
||||
{
|
||||
super(x, y, Paths.animateAtlas("charSelect/bfChill"));
|
||||
|
||||
desLp = anim.getFrameLabel("deselect loop start");
|
||||
|
||||
onAnimationComplete.add(function(animLabel:String) {
|
||||
if (hasAnimation("slidein idle point")) playAnimation("slidein idle point", true, false, false);
|
||||
else
|
||||
playAnimation("idle");
|
||||
switch (animLabel)
|
||||
{
|
||||
case "slidein":
|
||||
if (hasAnimation("slidein idle point")) playAnimation("slidein idle point", true, false, false);
|
||||
else
|
||||
playAnimation("idle", true, false, true);
|
||||
case "slidein idle point":
|
||||
playAnimation("idle", true, false, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var _addedCall = false;
|
||||
|
||||
override public function playAnimation(id:String, restart:Bool = false, ignoreOther:Bool = false, loop:Bool = false, startFrame:Int = 0):Void
|
||||
{
|
||||
if (id == null || id == "") id = "idle";
|
||||
switch (id)
|
||||
{
|
||||
case "idle", "slidein idle point":
|
||||
if (!_addedCall)
|
||||
{
|
||||
var fr = anim.getFrameLabel("idle end");
|
||||
if (fr != null) fr.add(() -> {
|
||||
playAnimation("idle", true, false, false);
|
||||
});
|
||||
}
|
||||
_addedCall = true;
|
||||
|
||||
case "select":
|
||||
if (_addedCall)
|
||||
{
|
||||
anim.getFrameLabel("idle end").removeCallbacks();
|
||||
_addedCall = false;
|
||||
}
|
||||
|
||||
var fr = anim.getFrameLabel("deselect");
|
||||
|
||||
fr.add(() -> {
|
||||
anim.pause();
|
||||
anim.curFrame--;
|
||||
});
|
||||
|
||||
_addedCall = true;
|
||||
|
||||
case "deselect":
|
||||
var og = anim.getFrameLabel("deselect");
|
||||
if (_addedCall)
|
||||
{
|
||||
og.removeCallbacks();
|
||||
_addedCall = false;
|
||||
}
|
||||
|
||||
var fr = anim.getFrameLabel("deselect loop end");
|
||||
|
||||
fr.removeCallbacks();
|
||||
fr.add(() -> playAnimation("deselect loop start", true, false, false));
|
||||
|
||||
_addedCall = true;
|
||||
|
||||
case "slidein", "slideout":
|
||||
if (_addedCall)
|
||||
{
|
||||
anim.getFrameLabel("deselect loop end").removeCallbacks();
|
||||
_addedCall = false;
|
||||
}
|
||||
default:
|
||||
if (_addedCall)
|
||||
{
|
||||
anim.getFrameLabel("idle end").removeCallbacks();
|
||||
_addedCall = false;
|
||||
}
|
||||
}
|
||||
super.playAnimation(id, restart, ignoreOther, loop, startFrame);
|
||||
onAnimationFrame.add(function(animLabel:String, frame:Int) {
|
||||
if (animLabel == "deselect" && desLp != null && frame >= desLp.index) playAnimation("deselect loop start", true, false, true);
|
||||
});
|
||||
}
|
||||
|
||||
public function updatePosition(str:String)
|
||||
|
@ -104,6 +55,8 @@ class CharSelectPlayer extends FlxAtlasSprite
|
|||
|
||||
playAnimation("slidein", true, false, false);
|
||||
|
||||
desLp = anim.getFrameLabel("deselect loop start");
|
||||
|
||||
updateHitbox();
|
||||
|
||||
updatePosition(str);
|
||||
|
|
|
@ -499,12 +499,8 @@ class CharSelectSubState extends MusicBeatSubState
|
|||
{
|
||||
ease: FlxEase.quartInOut,
|
||||
onComplete: (_) -> {
|
||||
var fr = playerChill.anim.getFrameLabel("deselect loop end");
|
||||
if (fr != null) fr.removeCallbacks();
|
||||
@:privateAccess
|
||||
playerChill._addedCall = false;
|
||||
playerChill.playAnimation("idle");
|
||||
gfChill.playAnimation("idle");
|
||||
playerChill.playAnimation("idle", true, false, true);
|
||||
gfChill.playAnimation("idle", true, false, true);
|
||||
}
|
||||
});
|
||||
pressedSelect = false;
|
||||
|
@ -645,20 +641,23 @@ class CharSelectSubState extends MusicBeatSubState
|
|||
nametag.switchChar(value);
|
||||
playerChill.visible = false;
|
||||
playerChillOut.visible = true;
|
||||
playerChillOut.anim.goToFrameLabel("slideout");
|
||||
playerChillOut.playAnimation("slideout");
|
||||
var index = playerChillOut.anim.getFrameLabel("slideout").index;
|
||||
playerChillOut.onAnimationFrame.add((_, frame:Int) -> {
|
||||
if (frame == playerChillOut.anim.getFrameLabel("slideout").index + 1)
|
||||
if (frame == index + 1)
|
||||
{
|
||||
playerChill.visible = true;
|
||||
playerChill.switchChar(value);
|
||||
gfChill.switchGF(value);
|
||||
}
|
||||
if (frame == playerChillOut.anim.getFrameLabel("slideout").index + 2)
|
||||
if (frame == index + 2)
|
||||
{
|
||||
playerChillOut.switchChar(value);
|
||||
playerChillOut.visible = false;
|
||||
playerChillOut.onAnimationFrame.removeAll();
|
||||
}
|
||||
});
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ class AlbumRoll extends FlxSpriteGroup
|
|||
{
|
||||
super();
|
||||
|
||||
newAlbumArt = new FlxAtlasSprite(640, 350, Paths.animateAtlas("freeplay/albumRoll/freeplayAlbum"));
|
||||
newAlbumArt = new FlxAtlasSprite(640, 360, Paths.animateAtlas("freeplay/albumRoll/freeplayAlbum"));
|
||||
newAlbumArt.visible = false;
|
||||
newAlbumArt.onAnimationComplete.add(onAlbumFinish);
|
||||
|
||||
|
@ -79,7 +79,7 @@ class AlbumRoll extends FlxSpriteGroup
|
|||
// Play the idle animation for the current album.
|
||||
if (animName != "idle")
|
||||
{
|
||||
// newAlbumArt.playAnimation('idle', true);
|
||||
newAlbumArt.playAnimation('idle', true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -643,6 +643,9 @@ class FreeplayState extends MusicBeatSubState
|
|||
// when boyfriend hits dat shiii
|
||||
|
||||
albumRoll.playIntro();
|
||||
var daSong = grpCapsules.members[curSelected].songData;
|
||||
albumRoll.albumId = daSong?.albumId;
|
||||
|
||||
|
||||
FlxTween.tween(grpDifficulties, {x: 90}, 0.6, {ease: FlxEase.quartOut});
|
||||
|
||||
|
|
Loading…
Reference in a new issue