Skip to content

Commit

Permalink
move camera with mouse press
Browse files Browse the repository at this point in the history
  • Loading branch information
mcagabe19 authored Aug 20, 2024
1 parent 1f15374 commit c234466
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion source/states/editors/CharacterEditorState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -873,6 +873,7 @@ class CharacterEditorState extends MusicBeatState implements PsychUIEventHandler
var holdingFrameTime:Float = 0;
var holdingFrameElapsed:Float = 0;
var undoOffsets:Array<Float> = null;
var cameraPosition:Array<Float> = [0, 0];
override function update(elapsed:Float)
{
super.update(elapsed);
Expand Down Expand Up @@ -900,6 +901,18 @@ class CharacterEditorState extends MusicBeatState implements PsychUIEventHandler
if (FlxG.keys.pressed.L) FlxG.camera.scroll.x += elapsed * 500 * shiftMult * ctrlMult;
if (FlxG.keys.pressed.I) FlxG.camera.scroll.y -= elapsed * 500 * shiftMult * ctrlMult;

var mouse = FlxG.mouse.getScreenPosition();
if (FlxG.mouse.justPressed && !FlxG.mouse.overlaps(UI_characterbox))
{
cameraPosition[0] = FlxG.camera.scroll.x + mouse.x;
cameraPosition[1] = FlxG.camera.scroll.y + mouse.y;
}
else if (FlxG.mouse.pressed && !FlxG.mouse.overlaps(UI_characterbox))
{
FlxG.camera.scroll.x = cameraPosition[0] - mouse.x;
FlxG.camera.scroll.y = cameraPosition[1] - mouse.y;
}

var lastZoom = FlxG.camera.zoom;
if(FlxG.keys.justPressed.R && !FlxG.keys.pressed.CONTROL) FlxG.camera.zoom = 1;
else if (FlxG.keys.pressed.E && FlxG.camera.zoom < 3) {
Expand Down Expand Up @@ -1323,4 +1336,4 @@ class CharacterEditorState extends MusicBeatState implements PsychUIEventHandler
_file.save(data, '$_char.json');
}
}
}
}

0 comments on commit c234466

Please sign in to comment.