mirror of
https://github.com/ninjamuffin99/Funkin.git
synced 2024-09-12 05:07:06 +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
|
class SprStage extends FlxSprite
|
||||||
{
|
{
|
||||||
|
public var layer:Int = 0;
|
||||||
|
|
||||||
public function new(?x:Float = 0, ?y:Float = 0)
|
public function new(?x:Float = 0, ?y:Float = 0)
|
||||||
{
|
{
|
||||||
super(x, y);
|
super(x, y);
|
||||||
|
@ -42,7 +44,9 @@ class SprStage extends FlxSprite
|
||||||
|
|
||||||
function dragShit(spr:SprStage)
|
function dragShit(spr:SprStage)
|
||||||
{
|
{
|
||||||
|
StageBuilderState.curSelectedSpr = this;
|
||||||
mousePressing = true;
|
mousePressing = true;
|
||||||
|
|
||||||
mouseOffset.set(FlxG.mouse.x - this.x, FlxG.mouse.y - this.y);
|
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.input.mouse.FlxMouseEventManager;
|
||||||
import flixel.math.FlxPoint;
|
import flixel.math.FlxPoint;
|
||||||
import flixel.ui.FlxButton;
|
import flixel.ui.FlxButton;
|
||||||
|
import flixel.util.FlxSort;
|
||||||
import flixel.util.FlxTimer;
|
import flixel.util.FlxTimer;
|
||||||
|
|
||||||
class StageBuilderState extends MusicBeatState
|
class StageBuilderState extends MusicBeatState
|
||||||
{
|
{
|
||||||
private var hudGrp:FlxGroup;
|
private var hudGrp:FlxGroup;
|
||||||
|
|
||||||
private var sprGrp:FlxGroup;
|
private var sprGrp:FlxTypedGroup<SprStage>;
|
||||||
|
|
||||||
// var snd:Sound;
|
// var snd:Sound;
|
||||||
// var sndChannel:SoundChannel;
|
// var sndChannel:SoundChannel;
|
||||||
|
@ -65,7 +66,7 @@ class StageBuilderState extends MusicBeatState
|
||||||
var bg:FlxSprite = FlxGridOverlay.create(10, 10);
|
var bg:FlxSprite = FlxGridOverlay.create(10, 10);
|
||||||
add(bg);
|
add(bg);
|
||||||
|
|
||||||
sprGrp = new FlxGroup();
|
sprGrp = new FlxTypedGroup<SprStage>();
|
||||||
add(sprGrp);
|
add(sprGrp);
|
||||||
|
|
||||||
hudGrp = new FlxGroup();
|
hudGrp = new FlxGroup();
|
||||||
|
@ -104,9 +105,9 @@ class StageBuilderState extends MusicBeatState
|
||||||
var awesomeImg:SprStage = new SprStage(FlxG.mouse.x, FlxG.mouse.y);
|
var awesomeImg:SprStage = new SprStage(FlxG.mouse.x, FlxG.mouse.y);
|
||||||
awesomeImg.loadGraphic(Paths.image('stageBuild/stageTempImg'), false, 0, 0, true);
|
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
|
// Load the image shit by
|
||||||
|
@ -127,16 +128,13 @@ class StageBuilderState extends MusicBeatState
|
||||||
#end
|
#end
|
||||||
}
|
}
|
||||||
|
|
||||||
function swagMousePress(spr:SprStage)
|
public static var curSelectedSpr:SprStage;
|
||||||
{
|
|
||||||
// spr.setPosition(FlxG.mouse.x, FlxG.mouse.y);
|
|
||||||
}
|
|
||||||
|
|
||||||
function loadImage():Void
|
function loadImage():Void
|
||||||
{
|
{
|
||||||
var img:FlxSprite = new FlxSprite().loadGraphic(Paths.image('newgrounds_logo'));
|
// var img:FlxSprite = new FlxSprite().loadGraphic(Paths.image('newgrounds_logo'));
|
||||||
img.scrollFactor.set(0.5, 2);
|
// img.scrollFactor.set(0.5, 2);
|
||||||
sprGrp.add(img);
|
// sprGrp.add(img);
|
||||||
}
|
}
|
||||||
|
|
||||||
function saveScene():Void
|
function saveScene():Void
|
||||||
|
@ -149,6 +147,21 @@ class StageBuilderState extends MusicBeatState
|
||||||
// trace(sndChannel.position);
|
// trace(sndChannel.position);
|
||||||
// trace(snd
|
// 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();
|
CoolUtil.mouseCamDrag();
|
||||||
|
|
||||||
if (FlxG.keys.pressed.CONTROL)
|
if (FlxG.keys.pressed.CONTROL)
|
||||||
|
@ -156,4 +169,16 @@ class StageBuilderState extends MusicBeatState
|
||||||
|
|
||||||
super.update(elapsed);
|
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