Skip to content

Instantly share code, notes, and snippets.

@ellemenno
Last active August 29, 2015 14:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ellemenno/0c550540442f024da1d2 to your computer and use it in GitHub Desktop.
Save ellemenno/0c550540442f024da1d2 to your computer and use it in GitHub Desktop.
minimal examples of Loom GUI and CLI apps

GUI Application

TestGUI.ls

package
{
    import loom.Application;
    import loom2d.display.StageScaleMode;
    import loom2d.ui.SimpleLabel;

    public class TestGUI extends Application
    {

        override public function run():void
        {
            stage.scaleMode = StageScaleMode.LETTERBOX;
            centeredMessage(simpleLabel, this.getFullTypeName());

            test();
        }

        private function get simpleLabel():SimpleLabel
        {
            return stage.addChild(new SimpleLabel("assets/Curse-hd.fnt")) as SimpleLabel;
        }

        private function centeredMessage(label:SimpleLabel, msg:String):void
        {
            label.text = msg;
            label.center();
            label.x = stage.stageWidth / 2;
            label.y = (stage.stageHeight / 2) - (label.height / 2);
        }

        private function test():void
        {
            trace('test');
        }
    }
}

osx

$ ~/.loom/sdks/sprint33/tools/lsc
$ ~/.loom/sdks/sprint33/bin/LoomDemo.app/Contents/MacOS/LoomDemo

win

> %userprofile%\.loom\sdks\sprint33\tools\lsc
> start "Loom" %userprofile%\.loom\sdks\sprint33\bin\LoomDemo.exe

CLI Application

TestCLI.build

{
    "name": "TestCLI",
    "version": "1.0",
    "executable": true,
    "outputDir": "./bin",
    "references": [
        "System"
    ],
    "modules": [
        {
            "name": "TestCLI",
            "version": "1.0",
            "sourcePath": [ "." ]
        }
    ]
}

TestCLI.ls

package
{
    import system.application.ConsoleApplication;

    public class TestCLI extends ConsoleApplication
    {
        override public function run():void
        {
            var arg:String;
            for (var i = 0; i < CommandLine.getArgCount(); i++)
            {
                trace('arg', i, ':', CommandLine.getArg(i));
            }
        }
    }
}

osx

$ ~/.loom/sdks/sprint33/tools/lsc TestCLI.build
$ ~/.loom/sdks/sprint33/tools/loomexec bin/TestCLI.loom --optionA arg1 arg2 -b

win

> %userprofile%\.loom\sdks\sprint33\tools\lsc TestCLI.build
> %userprofile%\.loom\sdks\sprint33\tools\loomexec bin/TestCLI.loom --optionA arg1 arg2 -b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment