Subscribe to GameFromScratch on YouTube Support GameFromScratch on Patreon
10. September 2012

 

The C++ mobile SDK Marmalade just announced release 6.1.

 

I suppose I can’t really refer to it as a mobile SDK any more, as one of the biggest features of 6.1 is the ability to target Windows and Mac OS desktops.

 

Other new features in this release are:

 

  • Target the desktop: With Marmalade 6.1 you can now deliver your apps to current Windows (7, Vista, XP) and Mac OS X platforms, as well as to Android MIPS devices and the latest LG Smart TVs.
  • Full flexibility: With Web Marmalade’s Plugins you can now mix HTML5 with native platform code, providing full flexibility and creativity.
  • Improved: Desktop graphics support, making it easier to develop and test Marmalade titles on a wide variety of desktop hardware.
  • Updated: You can now use floating-point within the graphics pipeline, allowing more intuitive manipulation of 3D assets.

 

 

Marmalade has been used to release a number of big name projects across many devices.  There is a free trial available, with pricing ranging from 149$ a year ( with a Splashscreen ), to 500$ a year ( no splash screen ) or a negotiated commercial license with full support ( including service level agreement ) and private beta access. 

 

One of the major features of the Marmalade SDK is the ability to target iOS without the need for a Mac.  I know there are a ton of small developers out there that want to make games for the iPhone and iPad, but don’t want to drop 1000$+ on an Apple computer.  If this description fits you, Marmalade might be the perfect option!

News


5. September 2012

 

In this section we are going to do something we probably shouldn’t… work with the keyboard.  As you will soon see, when dealing with mobiles, this isn’t a particularly smooth journey! Mobile and keyboards go together like peanut butter and hand grenades.

 

As is always the way, let’s jump right in with code:

 

screenWidth = MOAIEnvironment.screenWidth
screenHeight = MOAIEnvironment.screenHeight
print("Starting up on:" .. MOAIEnvironment.osBrand);

if screenWidth == nil then screenWidth =640 end
if screenHeight == nil then screenHeight = 480 end

MOAISim.openWindow("Window",screenWidth,screenHeight)

viewport = MOAIViewport.new()
viewport:setSize(screenWidth,screenHeight)
viewport:setScale(screenWidth,screenHeight)


layer = MOAILayer2D.new()
layer:setViewport(viewport)

MOAIRenderMgr.pushRenderPass(layer)


chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'

font = MOAIFont.new()
font:loadFromTTF('comic.ttf',chars,60,72)


text = MOAITextBox.new()
text:setString('Press a key')
text:setFont(font)
text:setTextSize(60,72)
text:setYFlip(true)
text:setRect(-320,-240,320,240)
text:setAlignment(MOAITextBox.CENTER_JUSTIFY,MOAITextBox.CENTER_JUSTIFY)


if(MOAIInputMgr.device.keyboard) then
    print("Keyboard")
    MOAIInputMgr.device.keyboard:setCallback(
        function(key,down)
            if down==true then
                text:setString(string.char(tostring(key)))

            end
        end
    )
else
    print("No Keyboard")

    if(MOAIEnvironment.osBrand == "iOS")   then
        MOAIKeyboardIOS.showKeyboard()
        MOAIKeyboardIOS.setListener(MOAIKeyboardIOS.EVENT_INPUT,function(start,length,textVal)
            text:setString(textVal);
        end
        )
    else
        print("The keyboard is a lie");
        -- Android, no keyboard support :(
    end
end

layer:insertProp(text)

 

Here is the program in action:

 

image

 

Exciting eh?  Again, we are going to skip over the familiar bits and jump right in to the new stuff.

 

One thing you might notice compared to prior tutorials, the line:

 

print("Starting up on:" .. MOAIEnvironment.osBrand  .. " version:" .. MOAIEnvironment.osVersion)

 

Has changed to

 

print("Starting up on:" .. MOAIEnvironment.osBrand);

 

Why is this?  Well remember when I said it was up to the host to implement the various values in MOAIEnvironment.  Well, I finally got around to testing on iOS and apparently MOAIEnvironment.osVersion isn’t implemented, at least, it isn’t on the Simulator.  As I recommended earlier, never trust these values to exist on all platforms! In production code, be sure to check for Nil.

 

Now the new code, let’s start with:

chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'

font = MOAIFont.new()
font:loadFromTTF('comic.ttf',chars,60,72)

 

The first line is a string of characters representing the individual characters we are going to be using.  If you need additional characters ( such as punctuation ) be sure to add them to this string.  We then create a new MOAIFont object, then load the font from a ttf file, comic.ttf ( I copied from the Windows font directory, you cannot legally redistribute fonts you don’t license! ).  Regardless to where you got it from, be sure to place a ttf file in the same directory as main.lua.  I moai to create the font created at a font height of 60 pixels and at a resolution of 72dpi.

 

Next up:

text = MOAITextBox.new()
text:setString('Press a key')
text:setFont(font)
text:setTextSize(60,72)
text:setYFlip(true)
text:setRect(-320,-240,320,240)
text:setAlignment(MOAITextBox.CENTER_JUSTIFY,MOAITextBox.CENTER_JUSTIFY)

 

Now we are creating a MOAITextBox, which is a bit misleading in name, especially if you have done some prior WinForm or ASP.NET programming.  A MOAITextBox is simply a text area on screen, often referred to as a label or text area in other libraries.  We then set text’s string value to “Press a Key” using the setString() method, set the font to the font we created earlier with a call to setFont(), and set the text size and dpi to match the values we used to create the font.  Next we call setYFlip to invert the font.  For reasons I don’t completely understand, MOAI renders text upside down by default… so this inverts it to the proper position.  Next we position and size the MOAITextBox with a call to setRect, telling it to position centered and use our full 640x480 screen ( again, remembering that coordinates are relative to 0,0 being the middle of the screen ).  Finally we center the text horizontally and vertically within the text area with a call to setAlignment().

 

Now we actually deal with handling keyboard entry:

 

if(MOAIInputMgr.device.keyboard) then
    print("Keyboard")
    MOAIInputMgr.device.keyboard:setCallback(
        function(key,down)
            if down==true then
                text:setString(string.char(tostring(key)))

            end
        end
    )
else

 

Here we are testing to see if a MOAIInputMgr.device.keyboard has been defined.  If this value is assigned, it means we have a keyboard ( currently this means we are running on a PC or Mac host, but don’t expect that to stay true forever ).  If a keyboard is in fact available, we set a callback function to handle key input.  This callback takes the key code ( as a number ) and a boolean, indicating if it was pressed or released and will be called every time a key is pressed.  We check to see if the key was pressed ( as opposed to released ), and if so, we simply convert the key code to an actual character and display it in our text box.

 

However, if there isn’t a keyboard…

 

else
    print("No Keyboard")

    if(MOAIEnvironment.osBrand == "iOS")   then
        MOAIKeyboardIOS.showKeyboard()
        MOAIKeyboardIOS.setListener(MOAIKeyboardIOS.EVENT_INPUT,function(start,length,textVal)
            text:setString(textVal);
        end
        )
    else
        print("The keyboard is a lie");
        -- Android, no keyboard support :(
    end
end

 

First we check to see if we are running on an iOS device.  If we are, we display the on screen keyboard, then set an event listener using MOAIKeyboardIOS listening for EVENT_INPUT events.  We then set the typed value textVal to our text box, which will be the currently typed character.  Otherwise we assume we are running on Android in which case we are…

 

 

Screwed.  Basically.  As of exactly this moment, there is no MOAIKeyboardAndroid available, although one has been developed so it should be available soon.  Until then, you can’t really handle keyboard entry on Android, unless you extend the host yourself.  I will update this guide when Android support is officially added.  You may be thinking to yourself “what about my hardware keyboard, it surely works, right???”.  Actually no.  Alternatives do exist ( there is a GUI package with an onscreen keyboard included ) that we will cover later, but for now at least until Android keyboard support is made publically available, you are kinda screwed.

 

 

Finally, we add our MOAITextBox to the layer with a call to

layer:insertProp(text)

 

Now you are happily traveling along with full keyboard support in your application!  Well, unless of course you have an Android device, in which case you are probably sulking in a corner.

 

 

Programming


3. September 2012

 

 

Have I ever mentioned how much I hate

 

a) developing for Android

b) using Eclipse

c) developing for Android using Eclipse?

 

 

Well, I do.  So often you spend more time fighting the tools than you do fighting with code, and today was yet another example.

 

I have some Moai code that worked perfectly well, both in the Windows host and on my device.  I made some alterations to the Lua code testing it to work on iOS ( by the way, the process of getting Moai running on iOS is 10000000x times easier than getting it running on Android! ), so other than some scripting changes, I haven't changed a thing.

 

I load up Eclipse click Run and…

 

[2012-09-03 14:54:20 - DeviceMonitor] Failed to start monitoring 84ef7369

[2012-09-03 14:54:20 - DeviceMonitor] Failed to start monitoring 84ef7369

[2012-09-03 14:54:20 - DeviceMonitor] Failed to start monitoring 84ef7369

[2012-09-03 14:54:20 - DeviceMonitor] Failed to start monitoring 84ef7369

[2012-09-03 14:54:20 - DeviceMonitor] Failed to start monitoring 84ef7369

[2012-09-03 14:54:20 - DeviceMonitor] Failed to start monitoring 84ef7369

[2012-09-03 14:54:20 - DeviceMonitor] Failed to start monitoring 84ef7369

 

WTF?

 

So I kill off adb ( adb kill-server ) and restart it ( adb start-server ).  Still no luck.

 

I exit and restart Eclipse.  No luck

 

I reboot my computer and phone.  No luck

 

I switch devices and try a different Android device.  No luck

 

 

Want to know what it is?  USB3.

 

Seriously, ADB doesn’t play well with USB3, or at least Eclipse+ADB don’t play well with USB3.

 

I plug into a different port and everything is just fine.  Well, except a few more gray hairs that is. Sad smile

Totally Off Topic


28. June 2012

So, Google has just released the Android 4.1 SDK, so lets take a quick look it what’s in there jellybeenfor game developers.

  • Vsync support, screen refreshing at 16 ms
  • systrace, a new kernel level profilinge tool
  • input device querying
  • low level media codec access
  • multi-channel audio
  • audio pre-processing
  • audio chaining ( transition on audio effect to the next )
  • new renderscript extensions
  • improved HTML5 rendering speeds
  • improved JavaScript engine speeds

 

Well, that’s about it.  Audio get’s a pretty big boost in capability and it will be interesting to see the results of universal vsync.  Otherwise a pretty minor update. On the bright side, it shouldn’t really result in any more fragmentation.

 

From a non-gaming perspective, it also adds resizable widgets, smart updates ( only update the parts that changed!  Long overdue ), many new notification options and a bunch of graphical fluff.

 

So, how many years until 4.1 has more than a 1% install base?  Considering I am still waiting for my Galaxy Note to be upgraded from 2.3, I’m not holding my breath.

News


23. May 2012

It looks like GameFly, the Netflix of gaming, has decided to enter the mobile gaming space in a big way.

 

First, about a week back, it announced a partnership with Future US increasing their marketing reach:

 

The collaboration will encompass international 360-degree content, e-commerce and advertising. Both companies will also work on various content deals including cross-linking, mobile apps content and contextual e-commerce promotions.

The new deal will help grow GameFly's audience and revenue by tapping Future's established network of loyal gaming fans through both print and digital outlets, and will further GameFly's ability to offer promotions for mobile titles that can be downloaded directly from GameFly onto iOS and Android devices. Simultaneously, this partnership will advance Future's charge into the digital space by delivering an audience of over 10.8 million unique visitors, while expanding its GamesRadar network. Future's media offerings will also be diversified by representing GameFly's mobile app and GameFly Media in the advertising marketing sector.

 

Future US has a pretty impressive portfolio of gaming and tech magazines including PC Gamer as well as the official XBox and PlayStation magazines, so this is a pretty big deal for GameFly.

 

Then came todays big announcement of their iOS and Android development fund coupled with their upcoming Android game store:

GameFly will launch a development fund to support the creation of new mobile games, and expects to release its first title this summer. The company said it will seek to work with developers who are in the process of building great games but lack the financial resources necessary to properly publish and promote their efforts. GameFly is currently accepting submissions at [email protected].

 

The forthcoming GameFly GameStore, expected to reach Android smartphones and tablets in time for the holiday season, will curate thousands of recommended Android games and offer daily deals. Ratings and reviews from the gaming community will accompany all Android titles sold in GameFly GameStore; GameFly also will leverage its social networking platform to drive discovery via friend recommendations. The firm already offers a Game of the Day spotlight feature within its GameFly App for iOS.



Oddly enough, beyond the [email protected] email address, no official details at all have been released directly from GameFly.

 

In somewhat related news, Facebook have entered the mobile game space with their Send to Mobile, although their solution will utilize existing app stores.

Facebook has detailed how its upcoming dedicated games and applications solution App Center aims to help developers drive mobile installs through convenience for users.

When accessing apps through the mobile App Center, Facebook will redirect the user to the specific App Store or Google Play marketplace pages, or load the app if it has already been installed before.

A "Send to Mobile" button will also be added to the browser version of the App Center, which will automatically install the app on any device connected to the Facebook account. Facebook says that the simplicity of the approach will make it easier for developers to increase install bases for mobile games and apps.

 

Truly interesting times to be a indie game developer!  With the horrid job Google did with the Android market, it's nice to see Amazon, and soon GameFly and Sony enter the fray.  Hopefully more developers will start making money on Android gaming now! 

 

News


GFS On YouTube

See More Tutorials on DevGa.me!

Month List