Fixed matrix util
This commit is contained in:
@@ -4,6 +4,11 @@ import flixel.FlxCamera;
|
||||
import flixel.math.FlxPoint;
|
||||
import flixel.util.typeLimit.OneOfTwo;
|
||||
|
||||
interface IPrePostDraw {
|
||||
public function preDraw():Void;
|
||||
public function postDraw():Void;
|
||||
}
|
||||
|
||||
class MatrixUtil {
|
||||
public static function getMatrixPosition(sprite:FlxSprite, points:OneOfTwo<FlxPoint, Array<FlxPoint>>, ?camera:FlxCamera, _width:Float = 1, _height:Float = 1):Array<FlxPoint>
|
||||
{
|
||||
@@ -15,7 +20,15 @@ class MatrixUtil {
|
||||
nc.zoom = camera.zoom;
|
||||
nc.scroll.set(camera.scroll.x, camera.scroll.y);
|
||||
nc.pixelPerfectRender = camera.pixelPerfectRender;
|
||||
var isPostDraw = sprite is IPrePostDraw;
|
||||
var postDraw = isPostDraw ? cast(sprite, IPrePostDraw) : null;
|
||||
if(isPostDraw) {
|
||||
postDraw.preDraw();
|
||||
}
|
||||
@:privateAccess sprite.drawComplex(nc);
|
||||
if(isPostDraw) {
|
||||
postDraw.postDraw();
|
||||
}
|
||||
|
||||
var isFunkinSprite = sprite is FunkinSprite;
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ import funkin.backend.scripting.events.PointEvent;
|
||||
import funkin.backend.system.Conductor;
|
||||
import funkin.backend.system.interfaces.IBeatReceiver;
|
||||
import funkin.backend.system.interfaces.IOffsetCompatible;
|
||||
import funkin.backend.utils.MatrixUtil;
|
||||
import funkin.backend.utils.XMLUtil;
|
||||
import haxe.Exception;
|
||||
import haxe.io.Path;
|
||||
@@ -29,7 +30,7 @@ using StringTools;
|
||||
@:allow(funkin.desktop.editors.CharacterEditor)
|
||||
@:allow(funkin.game.StrumLine)
|
||||
@:allow(funkin.game.PlayState)
|
||||
class Character extends FunkinSprite implements IBeatReceiver implements IOffsetCompatible {
|
||||
class Character extends FunkinSprite implements IBeatReceiver implements IOffsetCompatible implements IPrePostDraw {
|
||||
public var isPlayer:Bool = false;
|
||||
public var curCharacter:String = 'bf';
|
||||
public var sprite:String = 'bf';
|
||||
@@ -195,29 +196,41 @@ class Character extends FunkinSprite implements IBeatReceiver implements IOffset
|
||||
public function isFlippedOffsets()
|
||||
return (isPlayer != playerOffsets) != (flipX != __baseFlipped);
|
||||
|
||||
public var ghostDraw:Bool = false;
|
||||
public override function draw() {
|
||||
var __reversePreDrawProcedure:Bool = false;
|
||||
|
||||
public function preDraw() {
|
||||
if (!ghostDraw) {
|
||||
x += extraOffset.x;
|
||||
y += extraOffset.y;
|
||||
}
|
||||
|
||||
if (isFlippedOffsets()) {
|
||||
|
||||
if (__reversePreDrawProcedure = isFlippedOffsets()) {
|
||||
__reverseDrawProcedure = true;
|
||||
flipX = !flipX;
|
||||
scale.x *= -1;
|
||||
}
|
||||
}
|
||||
|
||||
super.draw();
|
||||
|
||||
public function postDraw() {
|
||||
if (__reversePreDrawProcedure) {
|
||||
flipX = !flipX;
|
||||
scale.x *= -1;
|
||||
__reverseDrawProcedure = false;
|
||||
} else super.draw();
|
||||
}
|
||||
|
||||
if (!ghostDraw) {
|
||||
x -= extraOffset.x;
|
||||
y -= extraOffset.y;
|
||||
x += extraOffset.x;
|
||||
y += extraOffset.y;
|
||||
}
|
||||
}
|
||||
|
||||
public var ghostDraw:Bool = false;
|
||||
public override function draw() {
|
||||
preDraw();
|
||||
super.draw();
|
||||
postDraw();
|
||||
|
||||
if (!ghostDraw) {
|
||||
if (debugHitbox) drawHitbox();
|
||||
if (debugCamera) drawCamera();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user