Hey guys. I'm new to LibGDX and fairly new to Java. I do however have experience in other languages such as C#. I've read through a basic java book and am now moving on to libgdx..It seems a lot of the tutorials are outdated..I'm working on a basic brick breaker game and using this tutorial: http://code.google.com/p/libgdx/wiki/SimpleApp

I'm just using the camera and spritebatch code and such from it...but it doesn't seem to be working correctly. I'm getting an exception on the batch.draw method. When I run it, the application shows briefly, and it looks like the paddle is stretched across the screen, but then it shuts down with the exception. I've been searching around to no avail. I appreciate any help. I'll post my code below as it isn't much.

{EDIT} Actually, it doesn't throw an exception with the code below..but the paddle disappears and it's just a white screen.

usegl20 was set to false. I set it to true but got the same result. The size of the paddle image is 64x16. I'm not sure honestly what resolution..I just opened up paint and made a paddle image and saved as PNG. I'm guessing that is 24 bit?

Your exactly right..Thanks. I've been searching everywhere trying to figure it out. I've got a lot to learn. I see from that tutorial that it sets the coordinate system specified by the camera..I guess the camera didn't have a coordinate system specified. I should probably check into that next. Lol.

publicvoidcreate() {//sets up a camera to the viewport width/heightcam = newOrthographicCamera(); }

publicvoidresize(intwidth, intheight) {//update the camera with new viewportcam.setToOrtho(false, width, height);}

publicvoidrender() {Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);

//before rendering, you need to update the batch with the new camera matrixbatch.setProjectionMatrix(cam.combined);

batch.begin();// ... render sprites ... //batch.end();}

The projection matrix now expects coordinates in "screen-space" from the lower-left origin. So rendering a 25x25 sprite at (0, 0) will render it in the lower left corner, and rendering it at (5, 10) will render it 5 pixels to the right, and 10 pixels up.

Typically you would pass SpriteBatch to other classes (like your Ball or Paddle class's render method).

Another solution with LibGDX is to use the Stage and scene2D package. It has some added benefits that might come in handy down the road like hit-testing, integration with UI elements (tables, layouts, skins, etc), easing/tweening, etc.

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org