• Create Account

Banner advertising on our site currently available from just \$5!

# levela

Member Since 15 May 2012
Offline Last Active Private

### Libgdx camera - pixel issues

27 April 2013 - 07:58 AM

Hiho!

I am a game designer student who started working with box2d and Libgdx recently. My game idea relies on Box2D heavily, so I spent about a week learning Box2dWeb (which is the JavaScript port of Box2d), and learned hopefully most of the things that I am going to need

in the development process. You can see the end result here

When I got done with this, I took a dive into libgdx. Read a lot of tutorials and documentation, and managed to get most of the things already working, but I am stuck with the pixel to meter (and vica-versa) scaling system, therefore I can't get it working on my Android device.

Using Box2dWeb I could solve the scaling problem by setting up a scale variable, and dividing and multiplying with it. According to the web, 30pixel should be equivalent 1 meter, so I did the following:

```SCALE = 30;

...

var bodyDef			= new box2d.b2BodyDef();
bodyDef.type		= box2d.b2Body.b2_staticBody;
bodyDef.position.x	        = 400 / SCALE;
bodyDef.position.y	        = 600 / SCALE;
bodyDef.userData            = 'Ground';

```
var fixDef = new box2d.b2FixtureDef();
fixDef.density = 5;
fixDef.friction = 0.5;
fixDef.restitution = 0.9;

fixDef.shape = new box2d.b2CircleShape(50 / SCALE);

And after assigning a bitmap to it, it matched the shape of the box!

### Libgdx camera - pixel issues

27 April 2013 - 07:58 AM

Hiho!

I am a game designer student who started working with box2d and Libgdx recently. My game idea relies on Box2D heavily, so I spent about a week learning Box2dWeb (which is the JavaScript port of Box2d), and learned hopefully most of the things that I am going to need

in the development process. You can see the end result here

When I got done with this, I took a dive into libgdx. Read a lot of tutorials and documentation, and managed to get most of the things already working, but I am stuck with the pixel to meter (and vica-versa) scaling system, therefore I can't get it working on my Android device.

Using Box2dWeb I could solve the scaling problem by setting up a scale variable, and dividing and multiplying with it. According to the web, 30pixel should be equivalent 1 meter, so I did the following:

```SCALE = 30;

...

var bodyDef			= new box2d.b2BodyDef();
bodyDef.type		= box2d.b2Body.b2_staticBody;
bodyDef.position.x	        = 400 / SCALE;
bodyDef.position.y	        = 600 / SCALE;
bodyDef.userData            = 'Ground';
```

var fixDef  = new box2d.b2FixtureDef();

fixDef.shape  = new box2d.b2CircleShape(50 / SCALE);

And the ground was in pixel-perfect position, and when attached a bitmap to the ball, it matched as well! In Java, it is different..

I have followed a tutorial which made me set up an ortographic camera with a viewport of 48*32 meters, then positioned it in the center. I have tried the same method that I  used with Box2dWeb, but it didn't work.

I want my game to be playable on Android phones and PC as well, so I do not know how I should solve this problem (or how I should configure / resize the viewport) for different screen sizes, or just a simple screen size.

Ps.: Sorry for the half-finished post, clicked the wrong button as it seems.

### What language should I choose?

15 May 2012 - 08:25 AM

Hello gamedevs out there!

First of all, I have to admit that I'm totally new to game development. So please, don't eat me.

I know the basics of c# (handling files and data, structured arrays, kinda have some idea about classes and methods, but I ain't that sure about it yet.), because I had to use it on my matura exam. Well, and now, I would like to make a game. The main goal is that the game should run on the most popular platforms (Android, iOS mainly, but I'd be happy if it could be ran on web also). I've done some research, but I'm still not sure about which language I should choose.

XNA with MonoGame?
Java?
c++?

The game would be 2D, so if the engine doesn't support 3D then it's not a problem.

Thank you!

PARTNERS