Our new game Frog Cakes is coming along and will be ready shortly.
In the course of developing the title menu (see picture below) we had to work out a way to handle overlapping menu items. As you can see the Settings Option for example overlaps the NewGame option. Our first attempt at this was to create a series of bitmaps with transparent regions. Then add “tap” event handlers in Corona. This however did not work as it turns out that Corona does not take transparent regions into account when the images overlap. In retro spec this made perfect sense because in order to support this functionality Corona would need to be able to read the image texture. Reading a texture is not something that 3D engines do well. It tends to be a very slow operation and even though Corona is setup to do things in 2D it still uses Open GL as the rendering engine which means that it is really 3D. So this meant that we needed to come up with a way to handle this take in our LUA code.
In programming there are several ways this can be handled. We could define a polygon and then use the standard point in poly method but if you look at the menu items their shapes would require a lot of edges and the overlapping nature would possibly require multiple checks ordered from top to bottom. Also although you can’t really see it well in this picture there are holes where a menu item below shows though a higher level menu item. So after considering this method we discarded it and came up with another one.
Since performance was the primary consideration we opted to create a mask of the area and then change this mask into a LUA string table where each menu item was represented by 1,2,3,4 and the edges outside the menu item were represented by 0. This method simplified the code to select a menu item to an array look up. The code to do this is shown below. Nice fast and really pretty clean. The one concern that we had was that the size of the look up table might be a problem. The look up table wound up being 60K. Now if you remember we orginally tried using images with transparent regions. When you added up each images size the total came to 490K so using a lua table as a hit array wound up being significantly smaller! Would the polygon method be smaller? Yes we could reduce the table size to probably less than 200 bytes and if this were an embedded app where we needed to squeeze every possible byte out that might be a good idea.
In this case though using the table in this manner is faster than doing a point in poly algorithm. The lesson here I think is that elegance can sometimes not be the best solution. Sometimes the simple brute force solution turns out to really be the best solution to a programming problem.
Blight
function SelectMenuItem(event)
local menuItem = GetHit(event.x, event.y)
if ( menuItem == “1″) then
NewGame();
elseif ( menuItem == “2″) then
Settings();
elseif ( menuItem == “3″) then
Instructions();
elseif ( menuItem == “4″) then
HighScores();
end
end
function GetHit(x, y)
if ( x < 268 or x >= 480 ) then
return “0″
end
if ( y < 0 or y >= 320 ) then
return “0″
end
x = x – 267
y = y + 1
return string.sub(mainmenu_mask[y], x, x)
end
If you live in the great north west you may have noticed the snow and ice! For many parts of the country this is not a big deal, but here in the north west we do not get a lot of snow and when it does happen things tend to grind to a halt. Well except at Night Pen of course! One of the advantages or disadvantages, depending on how you see it of being a virtual company is that snow days don’t really affect work days. These events started me thinking this morning. What we need is a celebration and what better way to celebrate than with a contest. So as everyone knows Frogs are cold blooded and so when it gets colder they slow down.
This is a picture of froggy.
Froggy is the frog in our soon to be released game “Frog Cakes”. Froggy eats “Cup Cakes” instead of flies. The problem is that froggy does not have a name! Names as you probably know are very important to frogs. So, here is the contest. Name froggy for us!
The top 3 entries will receive a free copy of our game marble master! To enter simply post a comment to this topic with your suggested name why you think it should be the winning name. One entry per post and per user account. We will announce the winning entries March 10th.
Good luck,
Blight
We are proud to announce our first game Marble Master has been approved and is available for sale in the Apple App store. Marble Master is an extremely addictive and fun casual game where you arrange marbles in groups of 3 or more to score points. When a marble group is scored it is turned to a dark color. When you score enough points you get a white marble which has the special property of clearing the dark marbles.
Marble master is available from the Apple App store for 99 cents. In celebration of the new year, until January 2nd this application will be available in the app store for free! Yes that is right free until the new year. So download it and have a blast! Once this free promotion ends the application will be priced at 99 cents. So don’t despair if you miss this promotion. As always the cost for our apps will be kept low.







