Spine – 2D skeletal Animation software + runtimes KickStarter- discounted for 2 more days!

I funded this awhile ago, and it was very relevant for a project I was working on, but if you guys are interested- the KickStarter has it discounted quite a bit:

http://www.kickstarter.com/projects/esotericsoftware/spine

I’m using it instead of flash for animating characters for my game, and it does a good job, as well as being lightweight.

They also have runtimes for libGDX, cocos2d, and since they made their goals, AS3, C#, javascript, ect.

Made by one of the two guys who are the main contributers of LibGDX.

Definitely more than worth it if you intend to ever use 2d skeletal animation in a project.

I spent a couple months writing a AIR program to convert flash XML files into easily read XML/JSON files, then loading them into my game, and it is still quite a ways off their app (That also includes the program to actually animate).

You can also buy it not off their website, but for a bit extra outside of the KickStarter(if you can’t stand waiting 2 more days)
http://esotericsoftware.com/uncategorized/kickstarter-stretch-goals/

Zombie Marshmallows From Space!!!

I had worked on a flash prototype a few years ago, and enjoyed the basic gameplay, so finally got around to finishing it off enough to make it a basic game, and have it now on google play.

Try it out and let me know what you think!
https://play.google.com/store/apps/details?id=com.ackmi.zombiemarshmallows
Poster

Lots of stuff I’d still like to add, but want to see if people would be interested in it. The basic gameplay is fun, and has a lot of areas where I can expand on it/ enhance, add more stuff.

Box2D for Flash Games demos in LibGDX with Projects for Desktop, Android, and HTML5

banner

I recently reviewed Emanuele Feronato’s new book “Box2D for Flash Games”, and created all the demos from the book in FlashDevelop.
In this post, I wanted to bring them all into LibGDX, so that everyone could also see how to work in Box2D using LibGDX, to develop Android, Desktop, and HTML5 Box2D games.

I would recommend picking up his book if you are interested in Box2D, and want to understand these demos from his book better. His site is also one of the best for tutorials an examples for beginner and intermediate game developers. (http://www.emanueleferonato.com/2012/11/28/box2d-for-flash-games-book-is-on-the-shelves/)

Obviously the syntax between AS3 and Java are a little different, but most of the lines of code worked pretty well, only having to change variable declarations, of function capitalization.

The only large problem I ran into was the implementation of JBox2d on LibGDX for the HTML5 version of the project. Everything still built correctly, and works, but blocks begin randomly shifting and falling over, and I wasn’t able to discover a solution to this problem yet.

In Example 2.1, we build on chapter one by adding objects to our world, making them dynamic, and changing the material properties, to allow the objects to interact differently.


Download the source code for the eclipse projects for Desktop, Android, and HTML5

And so you can see how easy it is to setup a basic Box2D world in LibGDX, that compiles for Desktop, Android and HTML5:
(The main difference is that OpenGL/LibGDX use the bottom-left corner as 0,0 (normal Cartesian) , whereas Flash uses the top left as 0,0, with down increasing in y-value, so for any y-coordinates from AS3, you have to do SCREEN_HEIGHT-y_coord. Also, I keep track of screen scaling, to scale everything relative to screen size, since obviously most Android devices can’t display 640×480 resolution, and should be full screen, regardless)

package com.chrismweb.box2dforflashgames;


import java.util.Iterator;

import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.Texture.TextureFilter;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType;
import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.math.Vector3;
import com.badlogic.gdx.physics.box2d.Body;
import com.badlogic.gdx.physics.box2d.BodyDef;
import com.badlogic.gdx.physics.box2d.Box2DDebugRenderer;
import com.badlogic.gdx.physics.box2d.CircleShape;
import com.badlogic.gdx.physics.box2d.FixtureDef;
import com.badlogic.gdx.physics.box2d.PolygonShape;
import com.badlogic.gdx.physics.box2d.World;
import com.badlogic.gdx.physics.box2d.BodyDef.BodyType;


/**
 * ...
 * #Chp2.1 - Ball drop with bounce
 * @book by Emanuele Feronato
 * http://www.emanueleferonato.com/
 * Get it now @ http://www.packtpub.com/box2d-for-flash-games/book
 */

public class MyGdxGame implements ApplicationListener
{
	//for drawing
	private OrthographicCamera camera;
	private SpriteBatch batch;
	
	//
	Vector3 touchPoint;
	
	

	public static float SCREEN_WIDTH_ORIGINAL=640;
	public static float SCREEN_HEIGHT_ORIGINAL=480;
	
	public static float SCREEN_WIDTH=640;
	public static float SCREEN_HEIGHT=480;
	
	//for testing other screen resolutions quickly in the desktop version
//	public static float SCREEN_WIDTH=1280;
//	public static float SCREEN_HEIGHT=800;
	
	public static float BOX2D_WIDTH_SCALE=1;
	public static float BOX2D_HEIGHT_SCALE=1;
	
	//box2d variables
	private World world;
	private Box2DDebugRenderer debugRenderer;
	public static float PIXELS_PER_METER = 30.0f;
	
	//reset variables
	BitmapFont font;
	Rectangle rect_reset;
	private ShapeRenderer renderer;
	
	

	@Override
	public void create()
	{
		SCREEN_WIDTH= Gdx.graphics.getWidth();
		SCREEN_HEIGHT= Gdx.graphics.getHeight();
		
		//NOTE: with different screen sizes (on android for instance) the world will be setup as different sizes, so the mass of objects won't be the same.
		//you need to create the world the same size, and scale the camera, so that it behaves the same regardless of screen resolution
		BOX2D_WIDTH_SCALE=SCREEN_WIDTH_ORIGINAL/SCREEN_WIDTH;
		BOX2D_HEIGHT_SCALE=SCREEN_HEIGHT_ORIGINAL/SCREEN_HEIGHT;
		
		
		// setup the camera. In Box2D we operate on a
		// meter scale, pixels won't do it. So we use
		// an orthographic camera with a viewport of
		// 48 meters in width and 32 meters in height.
		// We also position the camera so that it
		// looks at (0,16) (that's where the middle of the
		// screen will be located).
		camera = new OrthographicCamera(PixToMeter(SCREEN_WIDTH)*BOX2D_WIDTH_SCALE, PixToMeter(SCREEN_HEIGHT)*BOX2D_HEIGHT_SCALE);
		camera.position.set(PixToMeter(SCREEN_WIDTH)/2*BOX2D_WIDTH_SCALE, PixToMeter(SCREEN_HEIGHT)/2*BOX2D_HEIGHT_SCALE, 0);
				
		batch = new SpriteBatch();
		
		touchPoint = new Vector3(0,0,0);

		Vector2 gravity=new Vector2(0.0f, -9.81f); //we have to flip ALL y values- AS3 uses down int he y duirection as increasing, whereas OpenGL uses UP in the y direction as positive
		Boolean sleep = true;
		world = new World(gravity, sleep);
		debugRenderer = new Box2DDebugRenderer();
		
		Setup();
		
		font = new BitmapFont(Gdx.files.internal("resources/fonts/arial-15.fnt"), false);
		font.setScale(1/BOX2D_HEIGHT_SCALE);
		
		rect_reset = new Rectangle(0, SCREEN_HEIGHT-30/BOX2D_HEIGHT_SCALE, 100/BOX2D_WIDTH_SCALE, 30/BOX2D_HEIGHT_SCALE);
		renderer = new ShapeRenderer();
		
		Gdx.app.log("MyGdxGame", "GAME STARTED");
		
	}
	
	private void ResetWorld()
	{
		Gdx.app.log("MyGdxGame", "Resetting world");
		Iterator iterator = world.getBodies();
		while(iterator.hasNext()) 
		{
	         Body body = iterator.next();
	         world.destroyBody(body);
		}
		Setup();
	}
	
	public void Setup()
	{
		//for creating a circle
		//first create a bodydef
		BodyDef bodyDef = new BodyDef();
		bodyDef.position.set(PixToMeter(SCREEN_WIDTH_ORIGINAL/2), PixToMeter(SCREEN_HEIGHT_ORIGINAL-30));
		bodyDef.type = BodyType.DynamicBody;
		
		CircleShape circleShape = new CircleShape();
		circleShape.setRadius(PixToMeter(25));
		
		FixtureDef fixtureDef = new FixtureDef();
		fixtureDef.shape=circleShape;
		fixtureDef.density=1;
		fixtureDef.restitution=0.6f;
		fixtureDef.friction=0.1f;
		Body theBall = world.createBody(bodyDef);
		theBall.createFixture(fixtureDef);
		
		//for creating the "floor" bottom rectangle
		bodyDef.type=BodyType.StaticBody;
		bodyDef.position.set(PixToMeter(SCREEN_WIDTH_ORIGINAL/2), PixToMeter(SCREEN_HEIGHT_ORIGINAL-470));//center location of the box- 320 to the right (640/2), and 10px from the bottom(480)
		PolygonShape polygonShape=new PolygonShape();
		polygonShape.setAsBox(PixToMeter(SCREEN_WIDTH_ORIGINAL/2), PixToMeter(10));//1/2 width and height, so 640x20 px box
		fixtureDef.shape=polygonShape;
		Body theFloor=world.createBody(bodyDef);
		theFloor.createFixture(fixtureDef);
	}
	
	private float PixToMeter(float pixels)
	{
		return pixels / PIXELS_PER_METER;
	}
	private float MeterToPix(float meters)
	{
		return meters * PIXELS_PER_METER;
	}

	@Override
	public void dispose()
	{
		batch.dispose();

	}

	@Override
	public void render()
	{
		world.step(Gdx.app.getGraphics().getDeltaTime(), 3, 3);
		
		Gdx.gl.glClearColor(.2f, .2f, .2f, 1); //0->1 = 0->255
		Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
		camera.update();

		
		
		debugRenderer.render(world, camera.combined);
		
		
		
//		renderer.begin(type)
		renderer.setColor(.05f, .2f, .31f, 1.0f);
		renderer.begin(ShapeType.FilledRectangle);
		renderer.filledRect(rect_reset.x, rect_reset.y, rect_reset.width, rect_reset.height);
		renderer.end();
		
		batch.begin();
		font.drawMultiLine(batch, "Reset", rect_reset.x, rect_reset.y+font.getLineHeight(), rect_reset.width, HAlignment.CENTER);
		batch.end();
		
		Update();
	}
	public void Update()
	{
		// translate the mouse coordinates to world coordinates
		if (Gdx.input.justTouched()) 
		{
			camera.unproject(touchPoint.set(Gdx.input.getX(), Gdx.input.getY(), 0));
			Vector2 touchPointPixels =new Vector2(MeterToPix(touchPoint.x)/BOX2D_WIDTH_SCALE, MeterToPix(touchPoint.y)/BOX2D_HEIGHT_SCALE);
			
			Gdx.app.log("MyGdxGame", "GAME touchPointPixels: "+touchPointPixels);
			if(rect_reset.contains(touchPointPixels.x, touchPointPixels.y))
				ResetWorld();
		}
	}

	@Override
	public void resize(int width, int height)
	{
	}

	@Override
	public void pause()
	{
	}

	@Override
	public void resume()
	{
	}
}

After that, in Example 2.2 we also create a “Totem” game level, and create the totem object using compound objects to make a complex object from simple shapes.
We also create the head of the totem as a generic polygon, by specifying individual vertices to create the shape. (Blocks for some reason behave somewhat like jelly in the HTML5 with LibGDX and JBox2d)


Download the source code for the eclipse projects for Desktop, Android, and HTML5

In Example 3.1, we then learn how to convert mouse input to box2D meters, how to delete a body, and how to selectively get physical information about certain bodies that we are interested in.
(click on certain bodies to destroy them)


Download the source code for the eclipse projects for Desktop, Android, and HTML5

I will upload the rest of the demos and source code for each in the near future.

Our Fluffles Beta physics puzzle game released on Android Market!

Save the Fluffles! Fling them home through space in this new physics puzzle game
Help save the Fluffles and bring them home. Fling through space using your stored energy to get through the galaxy to get you back home with your friends. Carefully go through obstacles like spikes, black holes, and more! Help save the Fluffles and become a hero!
Have more fun with Fluffles by creating and playing your own levels with the built-in level editor. Challenge your friends and see if they can master your creations.
Don’t delay help the Fluffles today!
This physics based puzzle game is in the same category as Angry Birds. This is the BETA version. Like Minecraft, we will be continuously adding new features based on our players feedback. The initial release of the game includes the initial obstacles in 30 new levels. We will be adding more obstacles, powerups, enemies, and different environments! Help contribute to the advanced features being added into the game by leaving your feedback!

Download it Now!

Want it more challenging? More enemies, obstacles or features in the level designer? Let Us know! Just like the Fluffles, this game will evolve with your help!
Notes:
– Please send bug reports and feedback to info@ackmi.com
– This is the free version, supported with in app ads.
– Like us on Facebook: http://facebook.com/pages/Ackmicom/119310251495822
– Follow us on Twitter: http://twitter.com/ackmiENT
– Leave comments on our blog at: http://www.ackmi.com
Leave 5 stars to let us know you enjoy the game! If you leave less than 5 stars, please let us know what we can do to improve it to a 5-star rating!

Trouble getting windows 7 to recognize android device? Solution

I had to reinstall windows, and the Samsung galaxy (vibrant) refuses to allow me to install the drivers. I found the 64bit and 32bit (I am running windows 7 64 bit), and although it installed the drivers, the device would show up in device manager as just ‘sgh-t959’, and say ‘drivers not installed’ with a yellow exclamation mark on it.

I tried installing samsung KIES, running its ‘troubleshoot connection error’, which appeared to uninstall and reinstall the driver, and yet nothing.

FINALLY I found a solution to force windows 7 64bit to actually recognize that the drivers were installed:

  1. Right click on the device in device manager, and go to properties.
  2. Under the driver tab, select ‘update driver’
  3. Select ‘Browse my computer for the driver software’
  4. Now INSTEAD of selecting the folder with the drivers in, click on the bottom text ‘Let me pick from a list of device drivers on my computer’.
  5. Uncheck ‘show compatible hardware’, select your manufacture on the left (Samsung for mine, HTC if that is yours)
  6. Scroll down on the right and select the newest ‘SAMSUNG ANDROID ADB INTERFACE VERSION (mine was 5.14.0.0, from 2/5/2010, I selected the second one)
  7. Click next, ignore asinine warning

And viola, you have your device showing in the device manager without a yellow exclamation mark!

To test that it is actually working, if you have the android sdk, or adb, open a command prompt (‘cmd’ in the start->run box), go to your android sdk/platform-tools folder (cd c:\android-sdk\platform-tools or whatever folder your adb.exe is in), and type ‘adb devices’, and it should list your device.

Hope this helps someone- spent several days trying tons of drivers, have them all installed, yet windows wouldn’t assign the correct driver to the correct device. So +1 for forcing driver install!

Android 3.0 Animations: Beginner’s Guide Review

This was a good read if you are interested in adding animation to your android applications. It shows several different methods, from frame animation to tweening objects around on screen.

The book is titled for “Android 3.0”, but almost all of the examples will work for any version of Android. You just need to change the build target of the project properties to whatever SDK version you are using, and change the android manifest file from build 10 to 3.

It does touch on what the new animation methods are for Android 3.0, and you have a warning in the chapter for the exercise file that uses a newer version.

The examples may not all look pretty (especially the first one), but it teaches the main concepts, and you can fill in your own graphics, using the concepts, to add some nice ‘flair’ to your applications.

One of the more interesting examples shows you how to create your own, animated, and interactive ‘live wallpaper’, which you could use to create pretty much any type of live wallpaper.

The book does not go into OpenGL programming, but does introduce the concept of a “game loop”, which would be useful for someone to see who has never created a game before. A lot of the concepts might seem simple to someone who has experience using tweens, or frame by frame animation.

I would recommend this book to someone who has programmed on Android application before, but would like to add more “polish” to their application, using animation to liven it up.

You can pickup the book here: http://www.packtpub.com/android-3-0-animations-beginners-guide/book

Android 4.0 announcement!

Android 4.0 (Ice cream sandwich) has been announced, and so has the new Galaxy Nexus.

I am looking forward to this android update, and it is supposed to be a large one! It is supposed to be a combination of the divergent HoneyComb (3.0 series) OS for tablets, and the current gingerbread (2.3) for phones.

It looks to have a ton of new features, including:

  • A beautiful new user interface
  • Recent Apps button, that appears to work like the Windows 7 task manager
  • Unlocking the phone using facial recognition and the front facing camera
  • Swipe actions to dismiss notifications, browser tabs, ect.
  • Better keyboard
  • Ability to set warning and cutoff points for your data usage
  • Built in panoramic camera
  • Sharing information with other Android Devices using NFC by just touching them together
  • Faster Web browsing (with faster javascript engine)

It looks to be a fairy major update, and does resemble Honeycomb’s user interface.

I would bet on it being available on the new Galaxy Nexus when it is available (most likely, like usual, in early January or late December), and most likely slow updates coming out to all devices (although Android 4.0 isn’t supposed to have as much manufacture “skinning”, so it might roll out much faster).

You can see more details at the official Android 4.0 Platform highlight page:
http://developer.android.com/sdk/android-4.0-highlights.html

How to start creating android games using the LibGDX game development framework

UPDATE: There is a newer version of this article, which includes using the Setup GDX UI to create LibGDX projects much faster: http://chrismweb.com/2013/03/25/how-to-start-creating-android-games-using-the-libgdx-game-development-framework-updated-with-gdx-setup-ui-jar/

Why Android?

I’ve been creating games using flash/actionscript for a while now, but have really wanted to get started with android game development, since it’s an open source platform, the sky is the limit to how much you can learn about it.

The devices are usually fairly non-restrictive, being able to load custom roms, install any available software – even not directly through the market, being more practical (using internal storage as storage, not needing to install bloatware to connect to a computer), as well as having many more choices in hardware, since there is such a wide diversity of available mobile phones.

All in all, Android is very non-restrictive and flexible to it’s users, as well as it’s developers, and the market is supposed to be much easier to upload your app on, without getting turned down without a reason. It also caters more towards free apps (with ads), which is what I had wanted to offer, to allow everyone to be able to play my games.

Why LibGDX?

I have read a few android programming books, and most go into quite a bit of detail about application programming, but very little about OpenGL, not to mention I hadn’t done much programming using multiple separate threads in the past.

LibGDX takes care off pretty much all of the low-level stuff for you, so you can focus on game programming, or basic engine programming, and not about techniques for loading different image and music types, creating and handling multiple threads, or creating OpenGL surfaces to render 2d bitmaps on to.

Using it also does not take away any of the control you have, if you wanted to or needed to program lower level stuff, such as creating surfaces and 3d objects using OpenGL. Thus, it provides an excellent platform to get started with without having to worry about creating everything from scratch yourself, but also allows you to create things later on when you need them.

And for super-icing on the cake, it is specifically made for creating games, and it also allows you to compile and test using native Java on your computer before deploying to your android device, which makes debugging and compile time so much faster! No needing to deal with the android emulator for most of your design, unless you wish to, no needing to compile the apk, move it to the SD card, install, open, and finally debug- you can do it all on your computer before deploying to your android device!

So in summary:

  • Handles a lot of the stuff that you would normally need to program from scratch, saves you time, as well as allows you to expand it if needed
  • Specifically created for games!
  • Debug, test and try out your android app without having to rely on having a device/ emulator running almost all the time!
  • Open source and free, as well as great forums for support

So Now that you know why it is a great framework to use to develop android games, lets get up and running.
Continue reading

Flash Development for Android Cookbook Review


This is an awesome book to bring your Flash games and programs to Android!

This book provides you with everything you need to start developing programs and games on android using Adobe AIR, assuming you already have some knowledge in ActionScript.
It shows short “recipes” on how to interface with everything that you would want to on the phone, from gestures, drawing, acceleration and geolocation, camera, microphone, images, video, audio, local storage and SQLLite, to even putting the final app on the market.

Every recipe is well written, and specific to the interface you will be looking for, so you can easily find how to use the accelerometer, or load up the browser within your app. Most examples show how to do everything in Flash Builder (Flex), Flash ‘professional’, FDT, and even command line, so you have many options (although the code will work well in any of them).

The only negative I found with the book is that in Chapter 1, you learn how to compile, and run a program on Android, but Chapter 10 is when it actually goes into debugging, and setting up different configurations for testing your app. I wasn’t sure how to have the app test run in Windows instead of running on my Android directly until that chapter (although it is a cookbook- you pick which chapter is relevant what you’re trying to do).

If you have built applications or games using Flash/Flex before, and would like to have a version running on Android, this book will give you all the information you need, and is a great reference as well!

Get it now to get your Flash apps running on Android!

http://www.packtpub.com/flash-development-for-android-cookbook/book