How to use Rubeloader with libGDX and Intellij

General discussion about the R.U.B.E editor
Post Reply
chucknb28409
Posts: 1
Joined: Tue Sep 16, 2014 2:34 pm

How to use Rubeloader with libGDX and Intellij

Post by chucknb28409 »

I have setup a libGDX project and inported it without problems into Intellij. I want to use RUBE (I paid for the Pro version) to create and edit box2d scenes which means I have to use Rubeloader to convert the json files output by RUBE into something Intellij can work with, and that's my confusion. I clone the Rubeloader directory to directory in my workspace that is different (should it be different or the same one?) than the directory where I have my libGDX project. Rubeloader is setup for Eclipse do I have to change anything to use it for Intellij? Rubeloaders class paths point to Eclipse for jdk 1.6, and to an older version of box2d than what 1.31 libGDX uses. Do I correct these class paths before cloning?

I guess my confusssion comes from already having a project setup with libGDX, I don't believe it makes sense to override this by importing the Rubeloader project as descripbed in the Rubeloader ReadME. Can someone please explain the proper way to use Rubeloader with libGDX? Sorry for being such a newbie with this setup...

I have jdk 1.7 and jdk 1.8 installed with jdk 1.7 set as the system jdk through JAVA_HOME path.
I have gradle 2.0 installed with Intellij 13.1.4

Thanks
iforce2d
Site Admin
Posts: 861
Joined: Sat Dec 22, 2012 7:20 pm

Re: How to use Rubeloader with libGDX and Intellij

Post by iforce2d »

... convert the json files into something Intellij can work with
I don't get that part. If google serves me correctly Intellij is an IDE, which would not be working with the .json files at all, except perhaps to keep them in a list of resource files that need to be copied into the final bundle. But it should never need to open or load them, or 'work with' them in any other way.
Rubeloader is setup for Eclipse
I also don't get this part :) If I understand it correctly the classes used to load a RUBE scene are just regular Java classes, so it should not matter which IDE is being used to compile them. I'm pretty sure that behind the scenes, all IDEs will just be calling javacc to do the actual compiling.
Rubeloaders class paths point to Eclipse for jdk 1.6
Perhaps you are using too many of the files from the git repo for Rubeloader... I really doubt you would need anything that references Eclipse. I would think that you only need the folders/files under the 'src' folder here:
https://github.com/tescott/RubeLoader/t ... oader/src/
That would be a total of 14 .java files (and of course you need to preserve the folder structure as well, so you would add the topmost 'com' folder to your project).
iforce2d
Site Admin
Posts: 861
Joined: Sat Dec 22, 2012 7:20 pm

Re: How to use Rubeloader with libGDX and Intellij

Post by iforce2d »

To make that a little clearer, take a look at this code snippet from one of the .java files of Rubeloader:

Code: Select all

import com.badlogic.gdx.physics.box2d.joints.WheelJointDef;
import com.gushikustudios.rube.loader.serializers.utils.RubeImage;
The 'com.xxx.xxx' structure refers to package names, which will be organized in folders on your disk in the same structure. So somewhere in your source tree for libGDX, there will be a folder called 'com' with a subfolder called 'badlogic'. You would need to place the 'gushikustudios' folder of the Rubeloader there as well, alongside the 'badlogic' folder.
sysex
Posts: 6
Joined: Sun Oct 25, 2015 1:20 am

Re: How to use Rubeloader with libGDX and Intellij

Post by sysex »

hi, a few days ago I setup a working IntelliJ project with the loader from here: http://github.com/tescott/RubeLoader

Like Chris wrote , if you checkout the current commit of that repo you just have to copy these files from
the 'src' folder. Maybe its confusing because in IDEA there are Modules while in eclipse there are different projects?

1. Anyway from the eclipse core-project take just the files from the 'src'-folder and move them to the 'src'-folder of your already existing IDEA project's module 'core'.

In the IDEA Gradle project all other modules (Desktop, Androind..) are depending on this one, e.g. build target 'desktop' in the build.gradle
Here's a snippet from the generated build.gradle by ligGdx:

Code: Select all

project(":desktop") {
    apply plugin: "java"
    dependencies {
        compile project(":core")
        compile "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion"
        /..
    }
}
2. Move/export the Json-File and assets to the androids asset folder
3. In case you use the desktop build goal it's important to configure the run configuration of IDEA to use as 'Working directory' the Androids asset Folder as described here:
https://github.com/libgdx/libgdx/wiki/G ... ellij-IDEA under 'Running Your Project'

4. From that point on its on you how you want to use the loader. What I've written below is not IDEA specific and would work in eclispe too.
I took the code from

Code: Select all

com.gushikustudios.rube.RubeLoaderTest
from the eclipse rubeLoaderTest-project
and pasted it into a class which implements the libGdx Screen-Interface. The tescott's RubeLoaderTest-class constructor needs some parameters which I'll pass from the startup ApplicationListener in the core-module. This one gets invoked by the different build targets. I changed it to extend libGdx's Game-Class (which manages Screens and implement ApplictionListener by itself).

- In the core-module edit the ligGdx generated class which implements ApplicationListener to extend Game:

Code: Select all

public class MyApp extends Game {
	@Override
	public void create() {
		boolean useAssetManager = true;
                // pass the needed params to the RubeLoaderTest   
                setScreen(new RubeScreen(useAssetManager, 0));
	}
Put the code from 'com.gushikustudios.rube.RubeLoaderTest' in a new class which implements screen. Basically you just have to copy and paste the tescott's lines into the right methods from the Screen-Impementation, f.i. the create-method its called 'show' in Screen.

Code: Select all

public class RubeScreen implements Screen, InputProcessor, ContactListener
{
// omitted all the fields
   
  // here is the file list which gets adressed by the second param in the constructor
   private static final String [][] RUBE_SCENE_FILE_LIST =
   {
      {
         "data/palm.json"
      },
      {
         "data/base.json",
         "data/images1.json",
         "data/bodies1.json",
         "data/images2.json",
         "data/bodies2.json",
         "data/images3.json"
      }
   };
  // omitted fields

   public RubeScreen()
   {
      this(false);
   }
   
   // Here the constructors receive the params..

   public RubeScreen(boolean useAssetManager)
   {
      mUseAssetManager = useAssetManager;
   }
   
   public RubeScreen(boolean useAssetManager, int rubeFileList)
   {
      this(useAssetManager);
      mRubeFileList = rubeFileList;
   }
   
   @Override
   public void show()
   { 
     // ..
  }
  // omitted all fields and methods
}
Uhm, sorry probably this maks it confusing. Like I said Its just one alternative to make it work with all build targets. If this refactoring is working for you may want to separate the scene loading code from the updating/rendering code.

hope it helps - when it's done its really cool :D
Post Reply