atlas dragging + hitboxes

This commit is contained in:
lunarcleint
2025-03-08 04:42:09 -07:00
parent 224b35c070
commit 954828753e
5 changed files with 26 additions and 19 deletions
+2 -1
View File
@@ -39,11 +39,12 @@ class FakeCamera extends FlxCamera {
class FakeCallCamera extends FakeCamera {
public static final instance = new FakeCallCamera();
public var ignoreDraws:Bool = false;
public dynamic function onDraw(?frame:FlxFrame, ?pixels:BitmapData, matrix:FlxMatrix, ?transform:ColorTransform, ?blend:BlendMode, ?smoothing:Bool = false, ?shader:FlxShader) {
}
override function drawPixels(?frame:FlxFrame, ?pixels:BitmapData, matrix:FlxMatrix, ?transform:ColorTransform, ?blend:BlendMode, ?smoothing:Bool = false, ?shader:FlxShader) {
onDraw(frame, pixels, matrix, transform, blend, smoothing, shader);
if (!ignoreDraws) onDraw(frame, pixels, matrix, transform, blend, smoothing, shader);
}
}
+1 -1
View File
@@ -102,7 +102,7 @@ final class MatrixUtil {
// points should now contain the corners of the limb
trace("Corners of limb: " + points);
// trace("Corners of limb: " + points);
// set the max bounds of each corner of the limb
if(topLeft.x < boundsTopLeft.x) boundsTopLeft.x = topLeft.x;
@@ -382,6 +382,8 @@ class CharacterEditor extends UIState {
}
animationText.text = '"${characterFakeAnim}"';
StageEditor.calcSpriteBounds(character);
if (Options.characterDragging)
handleMouseOffsets();
@@ -406,15 +408,11 @@ class CharacterEditor extends UIState {
}
} else {
var point = FlxG.mouse.getWorldPosition(charCamera, _point);
if(character.animateAtlas == null) {
StageEditor.calcSpriteBounds(character);
var bounds:FlxRect = cast character.extra.get(StageEditor.exID("bounds"));
trace(bounds);
if (bounds.containsPoint(point)) {
cameraHoverDummy.cursor = #if (mac) DRAG_OPEN; #else CLICK; #end
if (FlxG.mouse.justPressed)
draggingCharacter = true;
}
var bounds:FlxRect = cast character.extra.get(StageEditor.exID("bounds"));
if (bounds.containsPoint(point)) {
cameraHoverDummy.cursor = #if (mac) DRAG_OPEN; #else CLICK; #end
if (FlxG.mouse.justPressed)
draggingCharacter = true;
}
}
}
@@ -1,5 +1,6 @@
package funkin.editors.character;
import funkin.backend.system.FakeCamera.FakeCallCamera;
import openfl.geom.ColorTransform;
import flixel.animation.FlxAnimation;
import funkin.game.Character;
@@ -14,7 +15,7 @@ typedef AtlasState = {
class CharacterGhost extends Character {
public var ghosts:Array<String> = [];
public override function draw() @:privateAccess {
ghostDraw = true;
ghostDraw = FakeCallCamera.instance.ignoreDraws = true;
var wasInvalidFrame:Bool = !colorTransform.__isDefault(false);
colorTransform.__identity();
@@ -46,7 +47,7 @@ class CharacterGhost extends Character {
if (ghosts.length > 0)
frame = frames.frames[animation.frameIndex];
}
ghostDraw = false;
ghostDraw = FakeCallCamera.instance.ignoreDraws = false;
alpha = 1; color = 0xFFFFFFFF;
if (wasInvalidFrame) {
@@ -55,6 +56,7 @@ class CharacterGhost extends Character {
colorTransform.color = 0xFFEF0202;
} else
setAnimOffset(animateAtlas != null ? atlasPlayingAnim : animation.name);
super.draw();
}
@@ -1,5 +1,7 @@
package funkin.editors.character;
import funkin.editors.stage.StageEditor;
import flixel.math.FlxRect;
import funkin.game.Character;
class CharacterGizmos extends FlxSprite {
@@ -20,8 +22,11 @@ class CharacterGizmos extends FlxSprite {
public function drawHitbox() {
for (camera in cameras) {
if (character.animateAtlas != null) {
// TODO: ATLAS CALCUATIONS
character._rect.set();
var bounds:FlxRect = cast character.extra.get(StageEditor.exID("bounds"));
character._rect.copyFrom(bounds.getDefault(FlxRect.weak()));
character._rect.x -= character.cameras[0].viewX;
character._rect.y -= character.cameras[0].viewY;
} else if (character._matrix != null && character.frame != null) {
character._rect.set(
character._matrix.tx, character._matrix.ty,
@@ -32,12 +37,13 @@ class CharacterGizmos extends FlxSprite {
if (character._matrix.d < 0) character._rect.y -= character._rect.height;
character._rect.offset(-character.cameras[0].viewMarginLeft, -character.cameras[0].viewMarginTop);
character._rect.x *= character.cameras[0].zoom;
character._rect.y *= character.cameras[0].zoom;
character._rect.width *= character.cameras[0].zoom;
character._rect.height *= character.cameras[0].zoom;
}
character._rect.x *= character.cameras[0].zoom;
character._rect.y *= character.cameras[0].zoom;
character._rect.width *= character.cameras[0].zoom;
character._rect.height *= character.cameras[0].zoom;
if (DrawUtil.line == null) DrawUtil.createDrawers();
DrawUtil.line.camera = camera; DrawUtil.line.alpha = 0.85;