Page 1 of 1

LibGDX and RUBE : body position.

Posted: Thu Jul 23, 2015 3:08 pm
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

Re: LibGDX and RUBE : body position.

Posted: Thu Jul 23, 2015 5:52 pm
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.

Re: LibGDX and RUBE : body position.

Posted: Fri Jul 24, 2015 12:24 pm
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...