Apr 172014

In October we started on a new project for iOS. This is a much bigger project in scope than our prior mobile apps, so we wanted a better way to manage our development than what we had with Ansca’s Corona SDK. There are a number of choices available today, and a LOT of them are free and Open Source. Compare that to a closed source SDK like Corona and it was a no brainer that we would move to something else.

Yes, the Corona SDK is LUA based and therefore extensible (mostly by the community), but that doesn’t help you when you need to access a Native API that Ansca didn’t feel was important enough to provide with their SDK. The functionality that you get with Corona is pretty good for the price, but if you want to do more than what it provides you have to spend $3000 on their “Enterprise” solution and that model only works for large developers, not the indie crowd.

The Pros and Cons of using Cocos2d-x

On the plus side, Cocos2d-x is open source, c++ based, and pretty easy to learn. You can using nice development tools like Visual Studio and do most of your development on a PC and then deploy your builds from your Mac. Or, if you have a little extra time to figure it out, you can use Marmalade with Cocos2d-x and deploy your apps right from your PC. How cool is that? Cocos2d-x has online documentation, but that is both a pro and con. The class hierarchy is all laid out nicely.

On the negative side, Cocos2d-x is a framework. That means a lot of things like IAP and Social Network integration are left to the developer. There is a decent community for Cocos2d-x and sometimes people share their code, but forum questions don’t seem to be actively responded to. That is just my initial experience with the forums, so it may change as I take the time to help other developers and get some assistance in return. The negative part of the Cocos2d-x documentation is that the online Reference pretty much is nothing more than a class hierarchy. I really don’t understand this since the .h files all appear to use Doxygen style comments, so it would have been very easy to have that put into the online documentation. Instead, if you want to know what a class does, or how a method works, you have to go to the .h file and read what is there, and if that isn’t enough go to the cpp file and figure out what the method is doing.

Using Cocos2d-x

Despite my comment in the Cons section that Cocos2d-x is just a framework, it is a pretty nice framework. In my next blog I will discuss getting started with Cocos2d-x and show how to write a simple app.

 Posted by at 4:53 pm
May 232012

We recently started on a fairly large mobile app. Our previous apps have been written using Ansca’s CoronaSDK (http://www.anscamobile.com/). For the most part Corona has met our needs, however recently we have had a lot of issues with stability. These issues have caused some negative reviews in the iTunes App Store. Also, there are some other features we would like to take advantage of that Corona does not currently support and may never support. There is no clear timeline for upcoming features.

Stability Issues
Some of the stability issues in the past few months include:

  • Full Screen Inneractive Ads lock up the app. This was recently fixed, but I reported this back in January. It is now May. Given that Ansca and Inneractive have both pushed using the Inneractive ad system since it was first introduced, you would have thought that this would have been a high priority bug to fix and not one that took 5 months to address.
  • Nook Color crashed at start up. Fixed in Build 819, but all that was required was a simple regression test to know it was broken. Read more here.

Additional Features Needed
These items really aren’t anything to complain about since there are plenty of apps that have no need for the same things we do, but for us these are issues worth noting:

  • LUA modules cannot be placed in sub folders
  • Texture memory is not optimized
  • Unable to extend the Corona API

LUA modules cannot be placed in sub folders
One of the key elements in our upcoming app is that it is essentially a collection of games in a single app. This means a LOT of assets, and a lot of different code modules to handle each games logic. Currently Corona does not support putting lua files in sub folders for all target devices. I’ve had success getting that to work on iOS devices, but it fails miserably on Android devices.

Texture memory is not optimized
Another issue with Corona has to do with texture memory. Corona uses one of two functions to load a texture:

-- Assume the image is 1024x768 and we want to display it
-- on a 480x320 device

local image1 = display.newImage( "image1.png" )
image1.scaleX = 480/1024
image1.scaleY = 320/768

local image1 = display.newImage( "image1.png", 480, 320 )
-- no need to scale since that is what the two params did,
-- BUT it still takes the same memory as the first call

In both cases the memory that the system will use for the texture is 1024x768xdepth. Ideally, we would want the second version to only take up 480x320xdepth bytes. This would mean we could have ONE high resolution image and use it on all platforms. Yes, we can do that now, but on the low resolution devices it will take the same amount of in app memory as the high resolution devices. This means that we have to create separate versions of the art for each resolution we want to support in order for the game to fit into memory. I really do not understand why they implemented it this way when all that had to be done was load the image into memory, resize it in code, then use the resized image for the actual texture display memory.

So the way we handle it is to create low, medium and high resolution versions of most images and put those in folders named “low”, “medium” and “high”; and a few we just have one version and dump those in a “common” folder.

Corona has something similar with their dynamic content scaling solution. However, this doesn’t address the texture memory issue, nor the bloat that comes from having to have multiple versions of key images.

With a proper load function we would be able to just have a common image and use it for whatever resolution we want by dynamically scaling the width and height for the actual device display resolution. Nice and memory efficient and we don’t double our APK or IPA size with copies of assets at different resolutions.

Unable to extend the Corona API
This issue along with the stability problems are probably the biggest reasons to consider moving away from Corona. Because Corona is not open source, we have to way to add features using platform API’s. I realize that is probably not the typical use of Corona as it was really targeted for Game Designers and not Game Programmers.

It would be fine if the community could request a feature and have a reasonable expectation that Ansca would add it to their API, but something as simple as pixel access to textures is still not in Corona and people have requested it for over a year.

Part 2 coming soon

P.S.: Like this article?! Want to support?! Be free to donate with bitcoins! 19r39vr2zs14aHW6DMNtPjmRga9xERQTTP

 Posted by at 2:28 am
Oct 132011

This example demonstrates a progress bar that updates while assets are being loaded.  The typical use is when your assets are large enough that the user might think your app has frozen if there isn’t some sort of feedback.

A few notes about the code below:

  • Because of the way that the Corona SDK scopes modules, I chose to have a global “World State” variable declared in main.lua so I can share values between modules. The name I chose for that variable is: gWS.  So if you see values prefaced with “gWS.” they are global values declared in main.lua
  • The gWS.nScaleX and gWS.nScaleY values are used to let me switch devices and have everything scale properly.
  • This example uses the “ui” and “director” modules from Ansca (included in the complete code on GitHug
  • The code is under the MIT license so feel free to use, modify, etc the code to your hearts content.

You can get the full source code along with assets from GitHub here

-- Date: October 12, 2011
-- Version: 1.0
-- File name: cSceneLoad.lua
-- Code type: Example Code
-- Author: Ken Rogoway
-- Update History:
-- Comments: The space images used are from NASA and are in the public domain.
--           The horse image sheets are from the horse demo provided by Ansca.
-- Sample code is MIT licensed:
-- Permission is hereby granted, free of charge, to any person obtaining a copy
-- of this software and associated documentation files (the "Software"), to deal
-- in the Software without restriction, including without limitation the rights
-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-- copies of the Software, and to permit persons to whom the Software is
-- furnished to do so, subject to the following conditions:

-- The above copyright notice and this permission notice shall be included in
-- all copies or substantial portions of the Software.

-- Copyright (C) 2011 Ken Rogoway. All Rights Reserved.

module(..., package.seeall)

local bUseListener = false
local nMeterX = 272     -- final X position of the meter bar when at 100 percent
local nMeterY = 562     -- Y position of the meter bar
local nMeterW = 480     -- Width of my meter bar image
local nMeterH = 30      -- Height of my meter bar image

-- This is set to 1/2 second (500 ms) so let it go slow enough to
-- see the bar advance since we are using a very small set of data
-- You would want to set this to a much smaller value, so there is
-- minimal delay between chunks, but probably at least 1/30 of a
-- second (33 ms) so there is time to update the display.
local nDelayBetweenChunks = 500

-- Main function - MUST return a display.newGroup()
function new()
    local splashGroup = display.newGroup()
    local loadingImage, loadingBar, loadingMask

    loadingImage = display.newImageRect( gWS.pImageDir.."load_bkgd.png", display.contentWidth, display.contentHeight )
    splashGroup:insert( loadingImage )
    loadingImage.x = display.contentCenterX
    loadingImage.y = display.contentCenterY

    loadingBar = display.newImageRect( gWS.pImageDir.."load_bar.png", math.floor( nMeterW * gWS.nScaleX ), math.floor( nMeterH * gWS.nScaleY ) )
    splashGroup:insert( loadingBar )

    loadingBar:setReferencePoint( display.TopLeftReferencePoint )
    loadingBar.x = math.floor( (nMeterX-nMeterW) * gWS.nScaleX )
    loadingBar.y = math.floor( nMeterY * gWS.nScaleY )

    loadingMask = display.newImageRect(	gWS.pImageDir.."load_mask.png", display.contentWidth, display.contentHeight )
    splashGroup:insert( loadingMask )

    loadingMask.x = display.contentCenterX
    loadingMask.y = display.contentCenterY

    -- Update the percent complete bar
    function updateBar()
        local nPercent = math.floor( 100 * (gWS.nLoadIndex-1) / gWS.nLoadCount )
        --print( "Percent = ", nPercent )
        loadingBar.x = math.floor( (nMeterX-nMeterW + (nMeterW*nPercent/100)) * gWS.nScaleX )
        if ( nPercent >= 100 ) then
            -- final resting place at 100 percent
            loadingBar.x = math.floor( nMeterX * gWS.nScaleX )

    function myLoadChunk()
        -- Load a chunk of data

        if ( bUseListener == false ) then
            -- update the loading bar.  See the comments above
            -- regarding using a event to trigger this

        -- Are there any chunks remaining?  If so, set a timer to
        -- load the next one.
        if ( gWS.nLoadIndex <= gWS.nLoadCount ) then
            timer.performWithDelay( nDelayBetweenChunks, myLoadChunk )
            -- Done, so finish any data stuff

            if ( bUseListener == true ) then
                Runtime:removeEventListener( "enterFrame", updateBar )

            -- Onward and outward
            director:changeScene( "cSceneGame" )

    -- Set everything up so we can start going

    updateBar()	-- update it once for 0 percent

    -- Start it going
    timer.performWithDelay( nDelayBetweenChunks, myLoadChunk )

    if ( bUseListener == true ) then
        Runtime:addEventListener( "enterFrame", updateBar )

    clean = function()

        if loadingImage then
            display.remove( loadingImage )
            loadingImage = nil

        if loadingBar then
            display.remove( loadingBar )
            loadingBar = nil

        if loadingMask then
            display.remove( loadingMask )
            loadingMask = nil

    -- MUST return a display.newGroup()
    return splashGroup


P.S.: Like this article?! Want to support?! Be free to donate with bitcoins! 19r39vr2zs14aHW6DMNtPjmRga9xERQTTP

 Posted by at 5:50 am

Please excuse my mess

 Uncategorized  Comments Off on Please excuse my mess
Oct 132011

For some reason my prior install of WordPress stopped working. I could see the blog entries, but couldn’t log in or admin the site.  Rather than wait on my ISP to update the version of PHP to something more recent, so I could reinstall the latest WordPress, I decided to use my ISP’s idiot proof installer to redo my site.

After getting the site set up, I had to go into my MySQL database for the prior blog entries and copy them into this new site.  Unfortunately this resulting in my site having a couple of the blog entries in the wrong order.  Everyone knows that “Hello World” should come first.

So please excuse my mess as I try and get things up and running again.

P.S.: Like this article?! Want to support?! Be free to donate with bitcoins! 19r39vr2zs14aHW6DMNtPjmRga9xERQTTP

 Posted by at 3:41 am

printf( “Hello world!” );

 Uncategorized  Comments Off on printf( “Hello world!” );
Oct 132011

“Hello World” is an apt title for my first blog post. Typically when you are learning a new programming language you start with a trivial application that outputs the message “Hello World” and since a person’s first blog post tends to be perfunctory it seems appropriate to leave the post with that title.

Let me introduce myself. My name is Ken Rogoway. I have been programming professionally for almost 30 years. The majority of that time has been spent writing video games, but I have also developed software for industries such as: insurance, audio processing, project management, biomedical and video processing for golf training. Currently I am developing casino games for the Class II and Class III markets.

I have a game centric biography on Moby Games that can be found here. My LinkedIn profile can be found here. Currently I am the Principal Engineer and Studio Director at a small casino development company.

The purpose of this blog should be fairly self evident based on the domain name. However, for those of you that prefer a written explanation, I decided to create this blog to discuss anything that comes to mind; whether or not it is programming related. In general I will tend to keep to technical issues, but as often happens in blogs I may digress into more personal and mundane topics from time to time.

P.S.: Like this article?! Want to support?! Be free to donate with bitcoins! 19r39vr2zs14aHW6DMNtPjmRga9xERQTTP

 Posted by at 3:17 am