Skip to content

UnderwaterApps/overlap2d-runtime-libgdx

Repository files navigation

##overlap2d-runtime-libgdx

The overlap2d-runtime-libgdx provides functionality to load, manipulate and render scenes generated by Overlap2D Editor. To be used with libGDX projects. Thanks to roboVM this will work also on iOS.

Overlap2D runtime is based on entity component system (which libGDX supportive incarnation is Ashley)

##IMPORTANT - old runtime users

If you were using the old runtime, and have to use it for your old projects, here is the url for all old resources: http://overlap2d.com/pre-0-1-0-stuff/

##Setting Up

If you are using gradle, yo can just add this line to your dependecies:

$ compile "com.underwaterapps.overlap2druntime:overlap2d-runtime-libgdx:0.1.2-SNAPSHOT

Otherwise just download this as sources, and include in your project by any means you see comfortable.

Important Make sure you also have libGDX, and free type fonts library in your dependencies.

When creating new project, why not use libGDX setup app? Here are the instructions: http://overlap2d.com/overlap2d-is-just-one-checkbox-away-with-libgdx-official-setup-app/

When generated the project, just make sure to change the version of overlap2d runtime to 0.1.2-SNAPSHOT (this will be updated soon)

##Using Spine with your o2d runtime Spine is not included by default, instead it's kind of an external plugin. Because Spine runtime is not in maven, here is the hell you have to go throguh:

  1. Get spine runtime for it's official github, and make sure it is included in your project.

  2. Add this to your settings.gradle:

    $ include 'spine-o2d-extension' $ project(':spine-o2d-extension').projectDir = new File(settingsDir, 'overlap2d-runtime-libgdx/extensions/spine')

  3. in your build.gradle, add this:

    project(":spine-o2d-extension") {
        apply plugin: "java"
        sourceSets.main.java.srcDirs = ["src/"]

        dependencies {
            compile project(":spine-runtime-libgdx");
            compile project(":overlap2d-runtime-libgdx");
            compile fileTree(dir: 'libs', include: '*.jar')
        }
    }

Also add this to dependencies: $ compile project(":spine-o2d-extension")

Also, after initializing scene loader, add: $ sceneLoader.injectExternalItemType(new SpineItemType());

##Getting started After you are all setup, and assets are exported, here is a sample code to get things rendered

in your create method:

    viewport = new FitViewport(800, 480); // this should be the size of camera in WORLD units. make sure you check that in editor first.
		sl = new SceneLoader(); // default scene loader loads allr esources from default RM as usual.
		sl.loadScene("MainScene", viewport); // loading scene as usual

in your draw method:

    Gdx.gl.glClearColor(0, 0, 0, 1);
		Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
		sl.getEngine().update(Gdx.graphics.getDeltaTime()); // getting the ashley engine and updating it (it will render things with it's own render system)