Archive for the ‘Android’ Category.

The libgdx/box2d Jumper tutorial

I have been too busy to finish the tutorial, and I’m not sure when I will get around to it. I know I’ve been leaving a bunch of people hanging for months, and for that I apologize.

However, I have good news. There’s better, neater software available for building graphics and fixtures for libgdx/box2d games: The Box2D Editor. The same person has created a better texture packer GUI and is working on a physics level editor. Way better than anything I was going to be showing you here!

Check out Aurelien Ribon’s Dev Blog.

Part 3 delayed

It turns out the projects I wrote for parts 1 and 2 do not work well on all devices. I’m working on the problem now — with the help of Ed in the comments from part 2. The process and TileCollisionTool will need some substantial changes. In particular, the tileset needs to be changed so that each tile has a bit of an edge around it.

libgdx, box2d, tiled maps: full working example, part 2/3

This is part 2 of a 3 part post demonstrating how to make a simple side scrolling game using libgdx and box2d. See part 1.

Updated 2011-09-19: Heh, now uses libgdx 0.9.2. No longer has its own Box2DDebugRenderer, figured out a better way using the new Matrix4 argument to renderer. Improved the controls by removing linear damping and replacing it with friction. (I am learning as I go with this, for what it is worth.) Discovered that I made a rather embarrassing mistake in leaving out rudimentary on-screen controls for Android devices. They are still pretty cruddy, though. Maybe I’ll come up with something better, or maybe someone else will and will contribute it? :) Either way is fine.

Updated 2011-09-18: Now uses libgdx 0.9.1.

In part 1 you saw how to make what is essentially a tiled map viewer. After you are through with this part you will have a character that you can move around the screen in a “natural” way, or at least a familiar way. As in part 1, download JumperTutorialProjects.zip for part 2 and follow along as the code is explained.

Continue reading ‘libgdx, box2d, tiled maps: full working example, part 2/3’ »

Delay on getting part 2 done

In part 2 I’ll be describing a way to add collision detection to a tiled map without having to draw the collision boundaries for the whole map. Instead, each type of tile will have its own collision boundaries (like, a floor tile will always have a collision boundary across its top). That way you’ll automatically get the collision rules set up at the same time as you draw your map. It’s a time-saver.

The problem is that figuring out the boundaries for each tile is pretty tedious, especially for tiles that have curves. I did this by hand for my own project, and I wrote up an explanation for how to do it. It was lengthy and, well, lame. I’m working on a web-based tool that will make this easier. Once that is done I will be able to complete part 2 and part 3.

So… it’s still “coming soon”.

libgdx, box2d, tiled maps: full working example, part 1/3

This will be a 3 part post demonstrating how to make a simple side scrolling game using libgdx (official project blog), a cross-platform library that allows you to simultaneously build for the desktop and for Android devices.

Updated 2011-09-19: Updated to use libgdx 0.9.2. No code changes required.

Updated 2011-09-18: Updated to use libgdx 0.9.1 (for real this time…) which meant renaming the pack file, TiledMapRenderer to TileMapRenderer, moving and renaming the tiles and pack file (and reindexing) due to new requirements from libgdx.

Updated 2011-06-12: Fixed some graphical glitches reported by Ed (in part 2′s comments). Thanks for all of your help Ed! Additionally, the tutorial is now based on libgdx 0.9.1 (it might have been libgdx 0.9.0 at the time, sorry folks) instead of an arbitrary nightly build, and it uses a modified TexturePacker in place of “manual” pack file generation.

This example is for anyone interested in making Android games, but is unsure where to start. By the end of part 3 you will have a basic Mario-like side-scrolling game with realistic physics, and (hopefully) you will be able to take this example and build something fun.

I’ve learned a few things since writing my previous post on using Tiled Map Editor with libgdx that I’ll apply in this series, things that make building a simple tiled-map game a lot easier. All code found here is released under the Apache 2.0 license, meaning, basically, you can use it for whatever you want. (IANAL, read the license for details.)

This is a much more involved tutorial than you have seen before on this site. There are a lot of different components used here and I tried to avoid cutting corners during explanations.

Continue reading ‘libgdx, box2d, tiled maps: full working example, part 1/3’ »

libgdx, Tiled Map Editor, TexturePacker, and you

libgdx has support for files created by the Tiled Map Editor, allowing you to easily create 2D orthogonal map scenes for your games. Once it’s up and running it is really neat. Getting it all to work requires careful setup, however. Updated 2011-03-20 after finding a critical problem found while following these steps again.

Continue reading ‘libgdx, Tiled Map Editor, TexturePacker, and you’ »

libgdx and TWL: Centering your layout

This won’t be a full on tutorial — it’s late, and I just now figured out how to do this — but I’m hoping that this will be helpful to others who go looking for a way to center their TWL layout within the screen, allowing you to do whatever it is you want around (behind) TWL.

As documented in TWL.java, libgdx is creating a root Widget that is set to take up the whole screen. So, if you want to center a TWL layout you’ll need to do it with TWL methods.

Continue reading ‘libgdx and TWL: Centering your layout’ »

libgdx and TWL

libgdx comes with a build of TWL, the Themeable Widget Library. This library can be used to build user interfaces including components like buttons, scrolling text areas, lists, clickable image maps, and so on. It allows the programmer to theme elements in a manner similar to the CSS. Neat. libgdx’s TWL class uses the SpriteBatch class to render components to the screen.

In this example I’ll describe how to add buttons and text components to a layout, and how to detect clicks on the components. The result will be a simple click/tap counter. This write-up is based on the TWL tests found in the libgdx source tree.

Continue reading ‘libgdx and TWL’ »