Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions engine/source/imaginative/backend/music/states/BeatState.hx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package imaginative.backend.music.states;

import imaginative.objects.MenuSprite;

/**
* It's just `FlxState` but with IBeat implementation. Or it would if it wasn't for this.
* `Field curStep has different property access than in backend.interfaces.IBeat ((get,never) should be (default,null))`
Expand Down Expand Up @@ -245,7 +247,25 @@ class BeatState extends FlxState /* implements IBeat */ {
super.update(elapsed);
}

var _menuBgs:Array<MenuSprite> = [];
override public function draw():Void {
_menuBgs = cast members.copy().filter((basic:FlxBasic) -> return basic is MenuSprite);
for (bg in _menuBgs)
bg.shouldDraw = false;
if (!_menuBgs.empty()) {
var index:Int = _menuBgs.length - 1;
var bg:MenuSprite = _menuBgs[index];
while (bg.alpha < 1 || !bg.visible) {
var newI:Int = index--;
if (newI == -1) break;
bg = _menuBgs[newI];
if (bg != null) break;
}
if (bg != null) {
bgColor = bg.blankBg.color;
bg.shouldDraw = true;
}
}
var event:ScriptEvent = eventCall('onDraw', new ScriptEvent());
if (!event.prevented) {
super.draw();
Expand Down
12 changes: 12 additions & 0 deletions engine/source/imaginative/objects/MenuSprite.hx
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,16 @@ class MenuSprite extends FlxSpriteGroup {
obj.updateHitbox();
}
}

@:allow(imaginative.backend.music.states.BeatState) var shouldDraw:Bool = true;
override public function draw() {
if (shouldDraw)
super.draw();
else {
var last:Bool = visible;
visible = false;
super.draw();
visible = last;
}
}
}