gf-tankmen optimisation
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
package funkin.desktop;
|
||||
|
||||
import flixel.util.FlxDestroyUtil.IFlxDestroyable;
|
||||
import flixel.FlxCamera;
|
||||
import openfl.events.Event;
|
||||
import flixel.FlxG;
|
||||
import lime.app.Application;
|
||||
import lime.ui.Window;
|
||||
|
||||
class DesktopScreen implements IFlxDestroyable {
|
||||
public var cameras:Array<FlxCamera> = [];
|
||||
public var window:Window;
|
||||
|
||||
public function new() {
|
||||
window = Application.current.createWindow({
|
||||
x: 0,
|
||||
y: 0,
|
||||
width: FlxG.width,
|
||||
height: FlxG.height
|
||||
});
|
||||
@:privateAccess
|
||||
Application.current.__addWindow(window);
|
||||
|
||||
window.stage.addEventListener(Event.ENTER_FRAME, onFrameEnter);
|
||||
|
||||
FlxG.signals.preDraw.add(__onPreDraw);
|
||||
FlxG.signals.postDraw.add(__onPostDraw);
|
||||
|
||||
window.onClose.add(destroy);
|
||||
}
|
||||
|
||||
public function addCamera(cam:FlxCamera) {
|
||||
cameras.push(cam);
|
||||
window.stage.addChild(cam.flashSprite);
|
||||
}
|
||||
|
||||
private inline function __onPreDraw() {}
|
||||
private inline function __onPostDraw() {}
|
||||
|
||||
private function onFrameEnter(event:Event) {
|
||||
try {
|
||||
@:privateAccess
|
||||
for(c in cameras)
|
||||
c.render();
|
||||
} catch(e) {
|
||||
trace(e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
public function destroy() {
|
||||
for(c in cameras)
|
||||
c.destroy();
|
||||
window.close();
|
||||
}
|
||||
}
|
||||
@@ -103,9 +103,20 @@ class MainMenuState extends MusicBeatState
|
||||
|
||||
if (!selectedSomethin)
|
||||
{
|
||||
if (canAccessDebugMenus)
|
||||
if (canAccessDebugMenus) {
|
||||
|
||||
if (FlxG.keys.justPressed.SEVEN)
|
||||
FlxG.switchState(new funkin.desktop.DesktopMain());
|
||||
if (FlxG.keys.justPressed.EIGHT) {
|
||||
var scr = new funkin.desktop.DesktopScreen();
|
||||
var camList = [for(c in FlxG.cameras.list) c];
|
||||
for(c in camList) {
|
||||
FlxG.cameras.remove(c, false);
|
||||
scr.addCamera(c);
|
||||
}
|
||||
cameras = camList;
|
||||
}
|
||||
}
|
||||
|
||||
if (controls.UP_P)
|
||||
changeItem(-1);
|
||||
|
||||
Reference in New Issue
Block a user