Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions source/funkin/game/Character.hx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ class Character extends FunkinSprite implements IBeatReceiver implements IOffset
public var iconColor:Null<FlxColor> = null;
public var gameOverCharacter:String = Character.FALLBACK_DEAD_CHARACTER;

/*
Whether to use the center or the top-left of the character as the camera origin point.
This is for compatibility with old texture atlas characters.
*/
public var centeredCamera:Bool = true;
public var cameraOffset:FlxPoint = FlxPoint.get(0, 0);
public var globalOffset:FlxPoint = FlxPoint.get(0, 0);
public var extraOffset:FlxPoint = FlxPoint.get(0, 0);
Expand Down Expand Up @@ -300,7 +305,7 @@ class Character extends FunkinSprite implements IBeatReceiver implements IOffset
}

public inline function getCameraPosition() {
var midpoint:FlxPoint = getMidpoint();
var midpoint:FlxPoint = centeredCamera ? getMidpoint() : getPosition();
var event = EventManager.get(PointEvent).recycle(
midpoint.x + (isPlayer ? -100 : 150) + globalOffset.x + cameraOffset.x,
midpoint.y - 100 + globalOffset.y + cameraOffset.y);
Expand Down Expand Up @@ -406,6 +411,10 @@ class Character extends FunkinSprite implements IBeatReceiver implements IOffset
if (hasInterval) beatInterval = Std.parseInt(xml.x.get("interval"));

loadSprite(Paths.image('characters/$sprite'));

if (xml.x.exists("centercam")) centeredCamera = (xml.x.get("centercam") == "true");
else centeredCamera = !isAnimate;

for(node in xml.elements) {
switch(node.name) {
case "anim":
Expand Down Expand Up @@ -438,7 +447,7 @@ class Character extends FunkinSprite implements IBeatReceiver implements IOffset

public static var characterProperties:Array<String> = [
"x", "y", "sprite", "scale", "antialiasing",
"flipX", "camx", "camy", "isPlayer", "icon",
"flipX", "camx", "camy", "centercam", "isPlayer", "icon",
"color", "gameOverChar", "holdTime", "applyStageMatrix"
];
public static var characterAnimProperties:Array<String> = [
Expand Down