Skip to content

Commit c2bdb1b

Browse files
frameOffset for atlases (need testing)
1 parent 546db6e commit c2bdb1b

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

source/funkin/backend/FunkinSprite.hx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,30 @@ class FunkinSprite extends FlxAnimate implements IBeatReceiver implements IOffse
376376
return val;
377377
}
378378

379+
override function draw():Void {
380+
if (isAnimate) {
381+
var posOffset:FlxPoint = FlxPoint.get(-frameOffset.x * scale.x, -frameOffset.y * scale.y);
382+
383+
var angleOff = angle;
384+
if (frameOffsetAngle != null)
385+
angleOff = frameOffsetAngle;
386+
angleOff *= FlxAngle.TO_RAD;
387+
388+
posOffset.rotateWithTrig(Math.sin(angleOff), Math.cos(angleOff));
389+
390+
x += posOffset.x;
391+
y += posOffset.y;
392+
393+
super.draw();
394+
395+
x -= posOffset.x;
396+
y -= posOffset.y;
397+
398+
posOffset.put();
399+
} else
400+
super.draw();
401+
}
402+
379403
override function drawComplex(camera:FlxCamera):Void
380404
{
381405
#if (flixel < "6.1.0") final frame = this._frame; #end

source/funkin/editors/character/CharacterAnimButton.hx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,19 @@ class CharacterAnimButton extends UIButton {
264264
var oldAnim:String = animData.anim;
265265
animData.anim = newAnim;
266266

267-
__refreshAnimation();
267+
var flxAnimation:FlxAnimation = __getFlxAnimation();
268+
flxAnimation.prefix = newAnim;
269+
270+
refreshFlxAnimationFrames(flxAnimation, animData);
271+
272+
if (valid) {
273+
parent.buildAnimDisplay(anim, data);
274+
animationDisplayBG.alpha = 1;
275+
} else {
276+
parent.removeAnimDisplay(anim);
277+
animationDisplayBG.alpha = 0.4;
278+
}
279+
268280

269281
if (parent.character.getAnimName() == anim)
270282
CharacterEditor.instance.playAnimation(anim);

0 commit comments

Comments
 (0)