"Flying Space Rocks" progress - fix for addBody after collision event in CoronaSDK

I have been building a simple Astroid clone as some of you know. Well I found a bug that really stopped me in my tracks. My understanding is that it's a bug with the Box2d logic that Corona uses for it's physics engine.

During a collision event you basically crash the application if you try to set any properties on any of the bodies that are being updated by the physics engine. I was able to get a crash by trying to call addBody and also by trying to do something simple like setting X and Y properties on a body that the physics engine was trying to update during the collision.

The fix really is pretty simple and I consider more of a "hack" than anything. You basically have to create an enterframe event and call your logic with in the enterframe function. This basically allows the physics update to complete and then you can act on the objects within the physics engine on the next frame. As you will see I create a local function with in the collision event that runs and then also removes the enterframe that we create as soon as we are done running our logic.

If anyone has a better solution please feel free to post in the comments.

The things that where crashing the app that are now fixed where the following. When a missel collides with a rock I wanted to create smaller rocks and then move the missel that was just used off screen so that it does not collied with any more objects till it is shot from the spaceship again.

Particle Candy for Corona SDK by Xpressive Games

Well I figured it was only a matter of time before some developers started building and releasing some pretty awesome tools for the Corona SDK. Enter "Particle Candy". I personally have not used it yet but I plan too. Something like this should be perfect for the exploding astroids in the game I am building

See more at x-pressive.com

Progress on "flying space rocks" using CoronaSDK

Just wanted to post my progress on the mobile development I have been doing with CoronaSDK. I started out building this game in Flixel in the Flash Player. Development was pretty easy and I got most everything ported over but there are of course some differences when it comes to working with the physics in Corona. (thanks Matthew Pringle for the help )

 

The problem I was running into was how to get the Rocks to fly around randomly and also detect when they move off screen in order to place them on the other side of the screen just like in the classic game. The forums on the ansca site proved to be very helpful after some tweaking on my end.

I am not sure if I am detecting the objects going off screen in a very good manner as there is more than likely a more optimized way of doing it. I am basically using an enterFrame event to check all the x and y locations and then preforming some checks to place the object where it needs to be if it goes off screen. Below is the code for applying the phisics and also my enter frame function that I am using.

 

 

Easy Screen Management in Corona

I have been messing around with the Corona SDK for a while. My goal is to have a game on the app store and the android market before then end of the year.

A small hang up that I was having was screen management. On the surface lua is really easy to learn but nothing is said about any good practices at all. As more of an OOP programmer it is essential that I am able to write my projects in a very modular way. Well luckily jonbeebe wrote a post about this very thing. Not so much a good OOP article as it is more of a way to organize your Corona projects into screens, so for me this is a good start. I am half way through my first game and the main.lua file was getting pretty large.

You can download the template that Jon has created below and I encourage you to take a look at the full article. It's not to long and very helpful

The Corona Project Template

I created an example that contains three files:

  • main.lua
  • screen1.lua
  • cheat-sheet.txt

You can download the project template here. It contains your main project file, an example screen template that you can duplicate for as many screens (or “scenes”) you need in your app, and a “cheat sheet” text file that’ll walk you through all the steps that need to be accomplished to add a new screen to your app (only 5 steps).

How to install Lua 5 in Mac OS X Leopard « Devthought

If you have darwin ports installed on OS X then you can follow the instructions below. If you don't want to go thorough the trouble of installing darwin ports just so you can use wget then you can just hop on over to the lua downloads and drop the tar file into the /tmp dir and follow the rest of the instructions

Open up terminal. Copy the link of the latest Lua version and download it:

cd /tmp
wget http://www.lua.org/ftp/lua-5.1.4.tar.gz

Extract and compile:

tar -xzvf lua-5.1.4.tar.gz
cd lua-5.1.4
make macosx

Test and install (if test goes through)

make test
sudo make install

And you’re done!

Physics in Five Lines

As a developer that considers himself more on the UI side of things I really enjoy sdks that make things easy and fast. Examples that I have used in the past when programing Flash are tools like Fuse, Tweener, TweenMax and APE.

I am excited to finally start getting into mobile development. I signed up to use the Corona SDK and I have yet to code anything that is ready for the app store. I am just futsing around with the API's right now but I am really excited to see that the Corona SDK team are making things like physics and animation really simple for the developers.