From 8e2eefb6050653e24606615136d8235946470e77 Mon Sep 17 00:00:00 2001 From: MtH Date: Sat, 7 May 2022 18:45:49 +0200 Subject: [PATCH] 0.2.8 character positions, dont multiply zoom, chara scaling fix --- source/funkin/play/PlayState.hx | 2 +- source/funkin/play/character/BaseCharacter.hx | 4 ++ source/funkin/play/stage/Stage.hx | 59 +++++++------------ 3 files changed, 27 insertions(+), 38 deletions(-) diff --git a/source/funkin/play/PlayState.hx b/source/funkin/play/PlayState.hx index adeff460c..1b4e652ec 100644 --- a/source/funkin/play/PlayState.hx +++ b/source/funkin/play/PlayState.hx @@ -650,7 +650,7 @@ class PlayState extends MusicBeatState implements IHook ScriptEventDispatcher.callEvent(currentStage, event); // Apply camera zoom. - defaultCameraZoom *= currentStage.camZoom; + defaultCameraZoom = currentStage.camZoom; // Add the stage to the scene. this.add(currentStage); diff --git a/source/funkin/play/character/BaseCharacter.hx b/source/funkin/play/character/BaseCharacter.hx index c3e40e50b..3f038e294 100644 --- a/source/funkin/play/character/BaseCharacter.hx +++ b/source/funkin/play/character/BaseCharacter.hx @@ -156,9 +156,13 @@ class BaseCharacter extends Bopper if (scale == null) scale = 1.0; + var feetPos:FlxPoint = feetPosition; this.scale.x = scale; this.scale.y = scale; this.updateHitbox(); + // Reposition with newly scaled sprite. + this.x = feetPos.x - characterOrigin.x + globalOffsets[0]; + this.y = feetPos.y - characterOrigin.y + globalOffsets[1]; } /** diff --git a/source/funkin/play/stage/Stage.hx b/source/funkin/play/stage/Stage.hx index 0d54ac91a..47a159f76 100644 --- a/source/funkin/play/stage/Stage.hx +++ b/source/funkin/play/stage/Stage.hx @@ -9,6 +9,7 @@ import funkin.modding.IScriptedClass; import funkin.modding.events.ScriptEvent; import funkin.modding.events.ScriptEventDispatcher; import funkin.play.character.BaseCharacter; +import funkin.play.stage.StageData.StageDataCharacter; import funkin.play.stage.StageData.StageDataParser; import funkin.util.SortUtil; import funkin.util.assets.FlxAnimationUtil; @@ -256,56 +257,40 @@ class Stage extends FlxSpriteGroup implements IHook implements IPlayStateScripte #end // Apply position and z-index. + var charData:StageDataCharacter = null; switch (charType) { case BF: this.characters.set("bf", character); - character.zIndex = _data.characters.bf.zIndex; - - // Start with the per-stage character position. - // Subtracting the origin ensures characters are positioned relative to their feet. - // Subtracting the global offset allows positioning on a per-character basis. - character.x = _data.characters.bf.position[0] - character.characterOrigin.x + character.globalOffsets[0]; - character.y = _data.characters.bf.position[1] - character.characterOrigin.y + character.globalOffsets[1]; - - character.cameraFocusPoint.x += _data.characters.bf.cameraOffsets[0]; - character.cameraFocusPoint.y += _data.characters.bf.cameraOffsets[1]; - - debugIcon.x = _data.characters.bf.position[0]; - debugIcon.y = _data.characters.bf.position[1]; - + charData = _data.characters.bf; character.initHealthIcon(false); case GF: this.characters.set("gf", character); - character.zIndex = _data.characters.gf.zIndex; - - character.x = _data.characters.gf.position[0] - character.characterOrigin.x + character.globalOffsets[0]; - character.y = _data.characters.gf.position[1] - character.characterOrigin.y + character.globalOffsets[1]; - - character.cameraFocusPoint.x += _data.characters.gf.cameraOffsets[0]; - character.cameraFocusPoint.y += _data.characters.gf.cameraOffsets[1]; - - // Draw the debug icon at the character's feet. - debugIcon.x = _data.characters.gf.position[0]; - debugIcon.y = _data.characters.gf.position[1]; + charData = _data.characters.gf; case DAD: this.characters.set("dad", character); - character.zIndex = _data.characters.dad.zIndex; - - character.x = _data.characters.dad.position[0] - character.characterOrigin.x + character.globalOffsets[0]; - character.y = _data.characters.dad.position[1] - character.characterOrigin.y + character.globalOffsets[1]; - - character.cameraFocusPoint.x += _data.characters.dad.cameraOffsets[0]; - character.cameraFocusPoint.y += _data.characters.dad.cameraOffsets[1]; - - // Draw the debug icon at the character's feet. - debugIcon.x = _data.characters.dad.position[0]; - debugIcon.y = _data.characters.dad.position[1]; - + charData = _data.characters.dad; character.initHealthIcon(true); default: this.characters.set(character.characterId, character); } + if (charData != null) + { + character.zIndex = charData.zIndex; + + // Start with the per-stage character position. + // Subtracting the origin ensures characters are positioned relative to their feet. + // Subtracting the global offset allows positioning on a per-character basis. + character.x = charData.position[0] - character.characterOrigin.x + character.globalOffsets[0]; + character.y = charData.position[1] - character.characterOrigin.y + character.globalOffsets[1]; + + character.cameraFocusPoint.x += charData.cameraOffsets[0]; + character.cameraFocusPoint.y += charData.cameraOffsets[1]; + + // Draw the debug icon at the character's feet. + debugIcon.x = charData.position[0]; + debugIcon.y = charData.position[1]; + } // Add the character to the scene. this.add(character);