While working on our latest project (Biffy directing this one), I ran into what seemed like a bug with collisions in Corona. I hadn’t got very far into the project yet, so the collisions were still pretty basic.
After looking over my code to see if it could possibly be my fault (and not a bug), I didn’t find anything and decided to submit a bug report to the Ansca Bugs team.
Here’s a closer look at what was going on…
The code I was working on involved shooting bullets at moving enemy targets. The crashes seemed to occur pretty randomly, which is why I thought it was a Corona bug. It didn’t occur on every collision though, and never after a specific number of collisions, so identifying it was a little frustrating.
After exchanging some emails with Ansca engineers, and doing more investigating on my own, it turns out it wasn’t a bug within Corona, but a limitation of the Box2D physics engine itself.
Special thanks to Carlos Icaza for a great contribution that will undoubtedly open up some possibilities for developers who otherwise would have no clue how to accomplish what he just did in the video (cough… me… cough).
The video shows two algorithms, a variant of the Douglas-Peucker polygon point reduction algorithm and Philip J Schneider’s CurveFit algorithm from Graphic Gems I with material from Philip’s book Geometric Tools for Computer Graphics, as well as material from Mark de Berg Computational Geometry and lastly, Gerald Farin’s Curves and Surfaces for CADG 5th Edition.
Infinitely useful, but also infinitely complicated. Thankfully, the source code will be made available soon so Corona developers can easily leverage Carlos’ hard work.
I’ve said it before, and I’ll say it again, the possibilities of the Corona SDK are endless. Carlos dug out books from way back before Corona even existed and was able to apply the same logic to a Corona project that’ll be soon be available to import into our own projects.
I’ll update this post once the source code is available, so stay tuned!
BeebeGames Class 1.6 Released. Per user request, added
event.count parameters to listeners passed to the
Top 5 Things the iPhone Has Given the World. Great read from PC World (ironically, since it’s about Apple):
In addition to making shareware trendy, the App Store did something much more important: It turned the cell phone into a computing platform.
Suddenly, cell phones could do just about anything, even if that usually equates to playing games. As Apple advertised, if you can find a task, there’s likely “an app for that.”
Again, this wasn’t entirely new. Significant amounts of money and time had been invested in making it possible to run Java applications on phones for years. However, Apple shifted the focus in a way only it can.
The iPhone personally changed my opinion about mobile platforms. Before the iPhone, I was a web developer who had no interest in focusing on mobile platforms. I heard about the iPhone in 2007, but still wasn’t interested.
Then, in 2008, I finally used one, and it changed all my preconceptions of mobile computing. When it comes to work, mobile is all I focus on now.
Useful Circular Movement Tutorial. The tutorial is for ActionScript, but the logic can be easily converted to Lua. Circular movement is kind of confusing, but useful for many animations in games. I might consider adding a related function to the BeebeGames Class eventually.
Outstanding Collision Filters Chart. Special thanks to Brent Sorrentino of Ignis Design LLC for this amazing resource.
Collision filters (a Box2D concept) is something that I have always been pretty confused about when it came to setting up new ones and how it all worked. The chart that Brent provided (back in October!) makes the whole thing a billion times simpler.
The page shows an example chart with step-by-step “how to” instructions, and then provides a link to a blank chart (PDF).
I recommend using an app such as Skim so you can draw on the PDF document and create a collision filter chart for each of your projects (that need it).
BeebeGames Class 1.5 Released. If you downloaded this class previously, this update is a MUST. It fixes a major bug that pretty much rendered the entire module useless if you used physics. Don’t worry, all of your previous code should work. I try my best to make each update backwards compatible so you’re not having to modify your code as you download new updates.
Here are a few more changes/fixes:
Better compatibility with Ricardo Rauber’s Director Class. In previous versions, sometimes you’d get errors while changing scenes. This update fixes that.
Added table to keep track of all objects created with newObject().
Added a function that allows you to destroy all objects created with newObject() all at once (destroyAllObjects).
I was going to wait until more features were added before releasing version 1.5 (because updates are coming VERY frequently), but after I ran into that big bug I knew I had to release this update right away.
I apologize for any inconvenience that the bug caused anyone in the meantime, but thankfully it’s fixed now.
BeebeGames Class Version 1.4 Released. A very small update that adds an onStart parameter to the doTransition method.
BeebeGames Class 1.3 Released. In additions to new things added in 1.2 today, this version includes a table that holds all active timers (timers that haven’t been canceled) as well as functions to pause, resume, and cancel all timers with one line respectively.
Also, I just published a tutorial on how to take advantage of all new additions in 1.2 and 1.3.
Combined, the BeebeGames Class version 1.2 and 1.3 features 6 new time-related functions, one of which being a complete replacement for the built-in timer.performWithDelay() as well as a—much requested—table that holds all active timers.
Before we get started on anything, you’ll want to import the beebegames.lua module into your project and localize the functions you’ll be using:
game = require( "beebegames" )
local resetTimeCounter = game.resetTimeCounter
local getCountedTime = game.getCountedTime
local performAfterDelay = game.performAfterDelay
local pauseAllTimers = game.pauseAllTimers()
local resumeAllTimers = game.resumeAllTimers()
local cancelAllTimers = game.cancelAllTimers()
resetTimeCounter() and getCountedTime()
These two functions go hand-in-hand and have to do with counting time as it passes. This can be useful for many different scenarios, for example, checking to see how long it took a player to complete a round… but I’ll leave the “when” up to you.