Skip to content
anakornk edited this page Apr 26, 2016 · 2 revisions

Getting Started

This guide assumes that you already have experience with making a simple HelloWorld application using libGDX, if not, check out [libGDX Documentation]https://libgdx.badlogicgames.com/documentation.html), and then come back here.

If you are using libGDX setup app, then you can add this runtime by ticking it's checkbox in third party extensions, which will add an appropriate gradle line. If not then you can add it by hand to build.gralde file yourself.

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

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

This guide also assumes you have downloaded the Overlap2D editor, learned how to use it, and made a sample scene with some assets in it. If no - check out Editor Howto, and then come back here. (When creating your o2d project, give it size 800x480 and 1pixel per world unit, this is just to keep it simple)

Now that you have both HelloWorld application, and a ready to export O2D scene, use Export Settings to export your assets into your libGDX project assets folder (make sure to clear it of other things first), it will be located either in core or android directory.

Awesome, we are ready to go! It's time to render the first scene.

Go to your application java class in core, and add following lines in 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

And this in your draw/render 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)

Now if you execute gralde "run" task, things should display properly.

From this point, you can proceed to programming your game logic. But You would strongly suggest reading about Runtime Architecture structure first.