mirror of
https://github.com/FunkinCrew/Funkin.git
synced 2025-03-25 22:29:42 -04:00
Merge branch 'sword352/indirect-anim-offsets' into bugfix/character-offset-fixes
This commit is contained in:
commit
492874ce32
2 changed files with 10 additions and 22 deletions
source/funkin/play
|
@ -118,22 +118,6 @@ class BaseCharacter extends Bopper
|
|||
*/
|
||||
public var cameraFocusPoint(default, null):FlxPoint = new FlxPoint(0, 0);
|
||||
|
||||
override function set_animOffsets(value:Array<Float>):Array<Float>
|
||||
{
|
||||
if (animOffsets == null) value = [0, 0];
|
||||
if ((animOffsets[0] == value[0]) && (animOffsets[1] == value[1])) return value;
|
||||
|
||||
// Make sure animOffets are halved when scale is 0.5.
|
||||
var xDiff = (animOffsets[0] * this.scale.x / (this.isPixel ? 6 : 1)) - value[0];
|
||||
var yDiff = (animOffsets[1] * this.scale.y / (this.isPixel ? 6 : 1)) - value[1];
|
||||
|
||||
// Call the super function so that camera focus point is not affected.
|
||||
super.set_x(this.x + xDiff);
|
||||
super.set_y(this.y + yDiff);
|
||||
|
||||
return animOffsets = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* If the x position changes, other than via changing the animation offset,
|
||||
* then we need to update the camera focus point.
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package funkin.play.stage;
|
||||
|
||||
import flixel.FlxSprite;
|
||||
import flixel.FlxCamera;
|
||||
import flixel.math.FlxPoint;
|
||||
import flixel.util.FlxTimer;
|
||||
import funkin.modding.IScriptedClass.IPlayStateScriptedClass;
|
||||
|
@ -97,12 +98,6 @@ class Bopper extends StageProp implements IPlayStateScriptedClass
|
|||
if (animOffsets == null) animOffsets = [0, 0];
|
||||
if ((animOffsets[0] == value[0]) && (animOffsets[1] == value[1])) return value;
|
||||
|
||||
var xDiff = animOffsets[0] - value[0];
|
||||
var yDiff = animOffsets[1] - value[1];
|
||||
|
||||
this.x += xDiff;
|
||||
this.y += yDiff;
|
||||
|
||||
return animOffsets = value;
|
||||
}
|
||||
|
||||
|
@ -351,6 +346,15 @@ class Bopper extends StageProp implements IPlayStateScriptedClass
|
|||
return this.animation.curAnim.name;
|
||||
}
|
||||
|
||||
// override getScreenPosition (used by FlxSprite's draw method) to account for animation offsets.
|
||||
override function getScreenPosition(?result:FlxPoint, ?camera:FlxCamera):FlxPoint
|
||||
{
|
||||
var output:FlxPoint = super.getScreenPosition(result, camera);
|
||||
output.x -= animOffsets[0];
|
||||
output.y -= animOffsets[1];
|
||||
return output;
|
||||
}
|
||||
|
||||
public function onPause(event:PauseScriptEvent) {}
|
||||
|
||||
public function onResume(event:ScriptEvent) {}
|
||||
|
|
Loading…
Add table
Reference in a new issue