mirror of
https://github.com/ninjamuffin99/Funkin.git
synced 2024-12-28 15:57:42 +00:00
drag n drop layer type beat
This commit is contained in:
parent
3f53371f30
commit
bab7c0130d
|
@ -7,6 +7,8 @@ import flixel.math.FlxPoint;
|
|||
|
||||
class SprStage extends FlxSprite
|
||||
{
|
||||
public var layer:Int = 0;
|
||||
|
||||
public function new(?x:Float = 0, ?y:Float = 0)
|
||||
{
|
||||
super(x, y);
|
||||
|
@ -42,7 +44,9 @@ class SprStage extends FlxSprite
|
|||
|
||||
function dragShit(spr:SprStage)
|
||||
{
|
||||
StageBuilderState.curSelectedSpr = this;
|
||||
mousePressing = true;
|
||||
|
||||
mouseOffset.set(FlxG.mouse.x - this.x, FlxG.mouse.y - this.y);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,13 +8,14 @@ import flixel.input.mouse.FlxMouseButton.FlxMouseButtonID;
|
|||
import flixel.input.mouse.FlxMouseEventManager;
|
||||
import flixel.math.FlxPoint;
|
||||
import flixel.ui.FlxButton;
|
||||
import flixel.util.FlxSort;
|
||||
import flixel.util.FlxTimer;
|
||||
|
||||
class StageBuilderState extends MusicBeatState
|
||||
{
|
||||
private var hudGrp:FlxGroup;
|
||||
|
||||
private var sprGrp:FlxGroup;
|
||||
private var sprGrp:FlxTypedGroup<SprStage>;
|
||||
|
||||
// var snd:Sound;
|
||||
// var sndChannel:SoundChannel;
|
||||
|
@ -65,7 +66,7 @@ class StageBuilderState extends MusicBeatState
|
|||
var bg:FlxSprite = FlxGridOverlay.create(10, 10);
|
||||
add(bg);
|
||||
|
||||
sprGrp = new FlxGroup();
|
||||
sprGrp = new FlxTypedGroup<SprStage>();
|
||||
add(sprGrp);
|
||||
|
||||
hudGrp = new FlxGroup();
|
||||
|
@ -104,9 +105,9 @@ class StageBuilderState extends MusicBeatState
|
|||
var awesomeImg:SprStage = new SprStage(FlxG.mouse.x, FlxG.mouse.y);
|
||||
awesomeImg.loadGraphic(Paths.image('stageBuild/stageTempImg'), false, 0, 0, true);
|
||||
|
||||
sprGrp.add(awesomeImg);
|
||||
awesomeImg.layer = sprGrp.members.length;
|
||||
|
||||
// FlxMouseEventManager.add(awesomeImg, swagMousePress, null, null, null, false, true, false, [FlxMouseButtonID.LEFT, FlxMouseButtonID.RIGHT]);
|
||||
sprGrp.add(awesomeImg);
|
||||
});
|
||||
|
||||
// Load the image shit by
|
||||
|
@ -127,16 +128,13 @@ class StageBuilderState extends MusicBeatState
|
|||
#end
|
||||
}
|
||||
|
||||
function swagMousePress(spr:SprStage)
|
||||
{
|
||||
// spr.setPosition(FlxG.mouse.x, FlxG.mouse.y);
|
||||
}
|
||||
public static var curSelectedSpr:SprStage;
|
||||
|
||||
function loadImage():Void
|
||||
{
|
||||
var img:FlxSprite = new FlxSprite().loadGraphic(Paths.image('newgrounds_logo'));
|
||||
img.scrollFactor.set(0.5, 2);
|
||||
sprGrp.add(img);
|
||||
// var img:FlxSprite = new FlxSprite().loadGraphic(Paths.image('newgrounds_logo'));
|
||||
// img.scrollFactor.set(0.5, 2);
|
||||
// sprGrp.add(img);
|
||||
}
|
||||
|
||||
function saveScene():Void
|
||||
|
@ -149,6 +147,21 @@ class StageBuilderState extends MusicBeatState
|
|||
// trace(sndChannel.position);
|
||||
// trace(snd
|
||||
|
||||
if (FlxG.keys.justPressed.UP)
|
||||
{
|
||||
if (curSelectedSpr != null)
|
||||
{
|
||||
if (curSelectedSpr.layer != 0)
|
||||
{
|
||||
curSelectedSpr.layer -= 1;
|
||||
sprGrp.members[curSelectedSpr.layer].layer += 1;
|
||||
}
|
||||
// NOTE: fix to account if only one layer is in?
|
||||
|
||||
sortSprGrp();
|
||||
}
|
||||
}
|
||||
|
||||
CoolUtil.mouseCamDrag();
|
||||
|
||||
if (FlxG.keys.pressed.CONTROL)
|
||||
|
@ -156,4 +169,16 @@ class StageBuilderState extends MusicBeatState
|
|||
|
||||
super.update(elapsed);
|
||||
}
|
||||
|
||||
function sortSprGrp()
|
||||
{
|
||||
sprGrp.sort(daLayerSorting, FlxSort.ASCENDING);
|
||||
|
||||
FlxMouseEventManager.reorder();
|
||||
}
|
||||
|
||||
function daLayerSorting(order:Int = FlxSort.ASCENDING, layer1:SprStage, layer2:SprStage):Int
|
||||
{
|
||||
return FlxSort.byValues(FlxSort.ASCENDING, layer1.layer, layer2.layer);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue