LibGDX and RUBE : body position.

General discussion about the R.U.B.E editor
Post Reply
rileyrg
Posts: 54
Joined: Sun Jul 19, 2015 11:42 am

LibGDX and RUBE : body position.

Post by rileyrg »

I'm probably missing something here very obvious to do with anchor position, relative positions etc. The image shows a tiled desktop layout showing RUBE editing my scene file where you can see body bee1 and intellij in a debugging session. I use the Rube loader here https://github.com/tescott/RubeLoader to load it and obtain a list of bodies. I also use getNamed(Body.class,"bee1") to get an array of bee1 bodies. There is one body so I use first() to get a reference. But the position is 0,0 as you can see in the debugger variable pane. The rube scene has it specifically set to 2,2. Please, put me out of my misery. What am I missing? (I double checked the exported json file I import too and the position in the json is indeed 2,2). I asked in #libgdx but noone there is familiar with rube.

Image url:

http://i.imgur.com/O6HjIVt.jpg
iforce2d
Site Admin
Posts: 861
Joined: Sat Dec 22, 2012 7:20 pm

Re: LibGDX and RUBE : body position.

Post by iforce2d »

Is this immediately after loading the scene or after you might have made some changes to it? If the exported file from RUBE has the correct values I don't think I can help you with what happens after that. The best place to ask is in the libgdx forums, there are a few threads there - if you can make a very simple case that reproduces the error somebody might take a look.
rileyrg
Posts: 54
Joined: Sun Jul 19, 2015 11:42 am

Re: LibGDX and RUBE : body position.

Post by rileyrg »

Immediately after. But, preparing a simple example thus:

Code: Select all

RubeSceneLoader loader = new RubeSceneLoader();
rubeScene = loader.loadScene(Gdx.files.internal(GameLevel.getResourceName(rubeName)));
Body b2d = rubeScene.getNamed(Body.class, "bee1").first();
Gdx.app.log("rube", String.valueOf(b2d.getPosition()));
All is good..... the call to getPosition() updates the position vector thus:

Code: Select all

	public Vector2 getPosition () {
		jniGetPosition(addr, tmp);
		position.x = tmp[0];
		position.y = tmp[1];
		return position;
	}
So : moral of the story is ... dont examine private data in the debugger and always use the get* functions...
Post Reply