1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2024-12-26 15:07:14 +00:00

0.2.8 character positions, dont multiply zoom, chara scaling fix

This commit is contained in:
MtH 2022-05-07 18:45:49 +02:00
parent bfce579cd5
commit 8e2eefb605
3 changed files with 27 additions and 38 deletions

View file

@ -650,7 +650,7 @@ class PlayState extends MusicBeatState implements IHook
ScriptEventDispatcher.callEvent(currentStage, event); ScriptEventDispatcher.callEvent(currentStage, event);
// Apply camera zoom. // Apply camera zoom.
defaultCameraZoom *= currentStage.camZoom; defaultCameraZoom = currentStage.camZoom;
// Add the stage to the scene. // Add the stage to the scene.
this.add(currentStage); this.add(currentStage);

View file

@ -156,9 +156,13 @@ class BaseCharacter extends Bopper
if (scale == null) if (scale == null)
scale = 1.0; scale = 1.0;
var feetPos:FlxPoint = feetPosition;
this.scale.x = scale; this.scale.x = scale;
this.scale.y = scale; this.scale.y = scale;
this.updateHitbox(); this.updateHitbox();
// Reposition with newly scaled sprite.
this.x = feetPos.x - characterOrigin.x + globalOffsets[0];
this.y = feetPos.y - characterOrigin.y + globalOffsets[1];
} }
/** /**

View file

@ -9,6 +9,7 @@ import funkin.modding.IScriptedClass;
import funkin.modding.events.ScriptEvent; import funkin.modding.events.ScriptEvent;
import funkin.modding.events.ScriptEventDispatcher; import funkin.modding.events.ScriptEventDispatcher;
import funkin.play.character.BaseCharacter; import funkin.play.character.BaseCharacter;
import funkin.play.stage.StageData.StageDataCharacter;
import funkin.play.stage.StageData.StageDataParser; import funkin.play.stage.StageData.StageDataParser;
import funkin.util.SortUtil; import funkin.util.SortUtil;
import funkin.util.assets.FlxAnimationUtil; import funkin.util.assets.FlxAnimationUtil;
@ -256,56 +257,40 @@ class Stage extends FlxSpriteGroup implements IHook implements IPlayStateScripte
#end #end
// Apply position and z-index. // Apply position and z-index.
var charData:StageDataCharacter = null;
switch (charType) switch (charType)
{ {
case BF: case BF:
this.characters.set("bf", character); this.characters.set("bf", character);
character.zIndex = _data.characters.bf.zIndex; charData = _data.characters.bf;
// 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];
character.initHealthIcon(false); character.initHealthIcon(false);
case GF: case GF:
this.characters.set("gf", character); this.characters.set("gf", character);
character.zIndex = _data.characters.gf.zIndex; charData = _data.characters.gf;
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];
case DAD: case DAD:
this.characters.set("dad", character); this.characters.set("dad", character);
character.zIndex = _data.characters.dad.zIndex; charData = _data.characters.dad;
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];
character.initHealthIcon(true); character.initHealthIcon(true);
default: default:
this.characters.set(character.characterId, character); 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. // Add the character to the scene.
this.add(character); this.add(character);