AppEasy for Marmalade Now Available

AppEasy for the Marmalade SDK Has Arrived

We have made a special version of AppEasy that allows Marmalade SDK developers to develop AppEasy mobile games and apps using a combination of AppEasy and the Marmalade SDK.

What is AppEasy for Marmalade?

AppEasy for Marmalade is a software development tool and set of libraries that are designed to bring cross platform native mobile game and application development to people from all walks of life. Our goal is to enable anyone (regardless of expertise) to develop their own apps using AppEasy and the Marmalade SDK for fun or for sale on a variety of app stores, including the Apple App Store, Google Play, Amazon Market and beyond.

How do we plan to accomplish this? AppEasy uses an easy to learn mark-up language similar to HTML but designed specifically for producing game and application content. For example, it is possible to create game characters complete with physics
and collision in only a few lines of mark-up. Its also equally possible to create complex user interface controls that are bound to remote data. We also cater for the more experienced developer that would like more control over their app. Our rich mark-up language (XOML) has support for a wide range of tasks including working with variables, events, actions, commands, programs, calling Lua scripts and much more.

IwGame Engine Libraries and headers are also provided that enable Marmalade developers to access the power of AppEasy from C/C++.

AppEasy is compatible with all Marmalade compatible platforms. AppEasy Project Manager is currently compatible with Windows XP / Vista and Windows 7

Who is it for?

AppEasy for Marmalade is designed to enable anyone that has basic knowledge of Microsoft Visual Studio to develop and deploy their own games and apps onto mobile phones and onto mobile app stores.

How Much Does It Cost?

At the moment AppEasy for Marmalade is currently free to use for all Marmalade SDK developers.

Where Can I Get It?

You can download the latest build of AppEasy for Marmalade from http://www.drmop.com/AppEasyMarmalade.zip. This beta release is locked to the root of the C drive so ensure that you unzip the file to C: or AppEasy may NOT work.

Where can I get Support?

Our web site provides lots of information to help get you started. AppEasy is also fully documented (see the docs folder in the AppEasy installation) as well as over 60 examples located in the examples folder. We also provide a support forum for all AppEasy users at http://www.appeasymobile.com/forum

IwGame 0.4 Coming Very Soon – IwGame is Going Portable


Awesome news. IwGame 0.4 is on its way, we are aiming for a release this week (with a little luck). Be warned there are a mass of changes and fixes as well as some awesome new features.

We are also abstracting the Marmalade SDK out of the IwGame engine so it can be easily ported to native platforms. This is not to say that we will no longer be supporting Marmalade, we still love Marmalade and it will remain a target platform that IwGame can link with, although you will require a Marmalade license to use the Marmalade version of IwGame.

This weeks release will not be fully portable as we have just started the platform abstraction process. We will be working on porting IwGame to Windows, Mac, iOS, Android, WP8 and possibly BlackBerry OS 10 over the coming months. The final portable version of the game engine (IwGame 0.5) will be renamed to give it its own identity. The tentative new name will be the “Core Engine”

Our aim is to provide a commercial grade stand alone cross platform mobile and desktop game and application SDK along with a rapid application development system that requires no compilers or IDE’s and simple single click deployment and testing.

Marmalade SDK Tutorial – Integrating LUA Script Language

This tutorial is part of the Marmalade SDK tutorials collection. To see the tutorials index click here

Its been a while since I wrote a Marmalade SDk tutorial and to be honest I’ve been itching for the chance to start them back up, so I freed up a little time today to bring you this new tutorial.

Ok, decided that it was high time that IwGame had a proper scripting language, so took a look around various scripting languages including LUA, Javascript and AngelScript. Whilst we like them all and would like to integrate them all at some point, our first choice is LUA.

And as I am a complete LUA noob I decided to write a short tutorial showing how to integrate LUA so a) everyone can see how “not so difficult” (had to avoid the word easy, because that would be wrong) it is to integrate LUA and b) so I don’t forget how to do it myself in the future

I have created a small Marmalade app called lua_test that demonstrates the following:

  • Execute a string containing lua commands
  • Load and execute a lua file from C
  • Load and execute a specific function in a lua file from C
  • Load a lua file that executes a C function

With these basics you should be able to integrate LUA into your own project quite easily.

I’m not going to pretend that I am now a LUA expert after spending but a few hours learning how to integrate it, but I know a few things now to be confident to write this tutorial.

Setting up the MKB to support LUA

The first thing you need to do is edit your projects MKB file and the following sections:

packages
{
    lua
}

subprojects
{
    lua
}

LUA is not distributed with Marmalade, instead it is downloaded from the code repository when you run your MKB file. When you open up your MKB file you will notice a new lua filter has been added

Note that the version of LUA that is supported by the Marmalade SDK is currently 5.1.4

LUA header files

In order to access LUA you need to include the headers. However as we are including C headers into a C++ app we need to let the compiler know. With that in mind we add the headers as follows:

[sourcecode language=”cpp”]
// LUA headers
extern "C"
{
#include "lua.h"
#include "lauxlib.h"
#include "lualib.h"
}
[/sourcecode]

LUA State

LUA holds no global variables so the interpreters current state has to be stored somewhere where it can be accessed from your code. In our simple examples, we create the LUA state using lua_open() which returns a pointer to the state then close it when we have finished using lua_close(). Ideally you would want to manage this pointer to the LUA state, depending on the scope and lifetime of LUA scripts in your app. All of our examples start and end with:

[sourcecode language=”cpp”]
// Open LUA
lua_State *lua = lua_open();

// Add LUA libraries (standard libraries are libraries of code that provide some basic functionality such as print)
luaL_openlibs(lua); // See http://www.lua.org/manual/5.1/manual.html#luaL_openlibs

//
// Do something with LUA
//

// Shut down the lua state
lua_close(lua); // See http://www.lua.org/manual/5.1/manual.html#lua_close
[/sourcecode]

LUA Stack

LUA passes information between C and LAU code via a stack. To pass information to a LUA function from C you push the name of the function that you wish to call onto the stack followed by any parameters that you wish to pass. When the LUA function returns it returns any return values (LUA can return multiple values) or an error on the stack. Similarly when calling a C function from LUA, LUA pushes the parameters onto the stack then calls the C function. The C function examines the parameters on the stack (C does not remove them, LUA removes them when it returns) and utilises the data passed from LUA, carries out some logic and returns.

More info on the LUA stack can be found at http://www.lua.org/pil/24.2.html

Calling a string containing LUA from C

Here’s some example code showing how to execute a piece of LUA contained within a string:

[sourcecode language=”cpp”]
void CallLuaString(const char* string)
{
s3eDebugOutputString("==== Calling a LUA string");

// Open LUA
lua_State *lua = lua_open();

// Add LUA libraries
luaL_openlibs(lua); // See http://www.lua.org/manual/5.1/manual.html#luaL_openlibs

// Pass the string to lua to execute
if (luaL_loadbuffer(lua, string, strlen(string), "line") == 0) // See http://www.lua.org/manual/5.1/manual.html#luaL_loadbuffer
{
if (lua_pcall(lua, 0, 0, 0) != 0)
{
// Output the error
s3eDebugOutputString(lua_tostring(lua, -1));

// Pop error message off the stack
lua_pop(lua, 1); // see http://www.lua.org/manual/5.1/manual.html#lua_pop
}
}

// Shut down the lua state
lua_close(lua); // See http://www.lua.org/manual/5.1/manual.html#lua_close
}
[/sourcecode]

In this example, we open LUA then ad the standard LUA libraries. We then load the supplied string as a LUA chunk using luaL_loadbuffer() then call it using lua_pcall(). If an error occurs then we display the error and pop it off the stack

Calling a LUA file from C

Our next example looks at how to call a LUA file from C, lets take a look at the code:

[sourcecode language=”cpp”]
void CallLuaFile(const char* lua_filename)
{
s3eDebugOutputString("==== Calling a LUA file");

// Open LUA
lua_State *lua = lua_open();

// Add LUA libraries
luaL_openlibs(lua); // See http://www.lua.org/manual/5.1/manual.html#luaL_openlibs

// Load our test LUA file
if (luaL_loadfile(lua, lua_filename) == 0) // See http://www.lua.org/manual/5.1/manual.html#lua_load
{
if (lua_pcall(lua, 0, 0, 0) != 0) // See http://www.lua.org/manual/5.1/manual.html#lua_pcall
{
// Output the error
s3eDebugOutputString(lua_tostring(lua, -1));

// Pop error message off the stack
lua_pop(lua, 1); // see http://www.lua.org/manual/5.1/manual.html#lua_pop
}
}

// Shut down the lua state
lua_close(lua); // See http://www.lua.org/manual/5.1/manual.html#lua_close
}
[/sourcecode]

We begin this example much like we did our previous example, but instead of load_buffer() we call luaL_loadfile(), which basically does the same thing except it loads the data from a file.

Calling a LUA function from C

This example gets a little more complicated as we need to begin dealing with pushing data onto the LUA stack. Lets take a look at the code:

[sourcecode language=”cpp”]
void CallLuaFunctionInFile(const char* lua_filename, const char* function_name, double arg0, double arg1)
{
s3eDebugOutputString("==== Calling a LUA function from C");

// Open LUA
lua_State *lua = lua_open();

// Add LUA libraries
luaL_openlibs(lua); // See http://www.lua.org/manual/5.1/manual.html#luaL_openlibs

// Load our test LUA file
if (luaL_loadfile(lua, lua_filename) == 0) // See http://www.lua.org/manual/5.1/manual.html#lua_load
{
// Init the loaded lua file
if (lua_pcall(lua, 0, 0, 0) == 0) // See http://www.lua.org/manual/5.1/manual.html#lua_pcall
{
// Push the name of the function that we want to call onto the stack
// NB: LUA uses a stack to pass information back and forth between LUA and C (see http://www.lua.org/pil/24.2.html)
lua_getglobal(lua, function_name); // Push function name that we want to call ontothe stack (see http://www.lua.org/manual/5.1/manual.html#lua_getglobal)
lua_pushnumber(lua, arg0); // Push function call argument 1
lua_pushnumber(lua, arg1); // Push function call argument 2

if (lua_pcall(lua, 2, 1, 0) != 0) // See http://www.lua.org/manual/5.1/manual.html#lua_pcall
s3eDebugOutputString(lua_tostring(lua, -1));
else
{
if (!lua_isnumber(lua, -1)) // http://www.lua.org/manual/5.1/manual.html#lua_isnumber
s3eDebugOutputString("Function muust return a value");
else
{
// Get th result returned from the LUA function
double result = lua_tonumber(lua, -1);
}
}
lua_pop(lua, 1); // see http://www.lua.org/manual/5.1/manual.html#lua_pop
}
}

// Shut down the lua state
lua_close(lua); // See http://www.lua.org/manual/5.1/manual.html#lua_close
}
[/sourcecode]

Much of the code remains the same as the previous example, where we initialise LUA, load a LUA file and execute it. The difference is that we now push an actual function name and a number of parameters onto the stack using lua_getglobal() and lua_pushnumber(). We then make another call to LUA which executes the LUA function that we just stacked, e then check the return value and if itis not a number we display an error otherwise we pop the returned number off the stack and store it locally.

Calling a C function from LUA

Things get a little more complicated when you find that you need to call C functions from LUA. The first thing that we need to do is let LUA know that our C function is available to be called as well as define a protocol for how it should be called from LUA. Lets take a look at an example:

[sourcecode language=”cpp”]
static int test_function(lua_State *lua)
{
double d = 0;
// Get the argument that was passed from lua
if (lua_isnumber(lua, 1))
d = lua_tonumber(lua, 1);
else
s3eDebugOutputString("test_function can only accept a number");

// Square it
d = d * d;

// Push the result back onto the stack as a return value
lua_pushnumber(lua, d);

// Return the number of result arguments that were passed back to lua
return 1;
}

void CallCFunctionFromLua()
{
s3eDebugOutputString("==== Calling a C function from LUA");

// Open LUA
lua_State *lua = lua_open();

// Add LUA libraries
luaL_openlibs(lua); // See http://www.lua.org/manual/5.1/manual.html#luaL_openlibs

// Push the test function
lua_pushcfunction(lua, test_function); // See http://www.lua.org/manual/5.1/manual.html#lua_pushcfunction

// Set the global test_function to the pushed C function
lua_setglobal(lua, "test_function"); // See http://www.lua.org/manual/5.1/manual.html#lua_setglobal

// Load our test LUA file
if (luaL_loadfile(lua, "lua_test3.lua") == 0) // See http://www.lua.org/manual/5.1/manual.html#lua_load
{
if (lua_pcall(lua, 0, 0, 0) != 0) // See http://www.lua.org/manual/5.1/manual.html#lua_pcall
{
// Output the error
s3eDebugOutputString(lua_tostring(lua, -1));

// Pop error message off the stack
lua_pop(lua, 1); // see http://www.lua.org/manual/5.1/manual.html#lua_pop
}
}

// Shut down the lua state
lua_close(lua); // See http://www.lua.org/manual/5.1/manual.html#lua_close}
}
[/sourcecode]

Firstly we create a C function called test_function() which is declared from LUA’s standard C function prototype:

static int test_function(lua_State *lua)

This function accepts a lua state which we can query for information that was passed to it by LUA (on the stack). In our example, we firstly check to see if the value on the top of the stack is a number, if not we display an error, if so then we retrieve that number. Next we modify the number then push it back onto the stack so that it can be retrieved (returned to) by the calling LUA function. Note that the value returned from our C function represents the number of arguments that we returned on the stack. Lets take a quick look at the LUA code that made the call to our C test_function in the first place:

d = test_function(12);
print(d);
d = test_function("hello");    -- This will cause an error because we passed a string instead of a number
print(d);

As you can see it calls test_function twice. The first time it is successful because we passed a number, the second time we passed a string which test_function() detected as an error.

Ok, lets now take a look at the code that registers our C function so that LUA can use it (see CallCFunctionFromLua() above)

Firstly we call lua_pushcfunction(lua, test_function); which places our C function onto the stack. Next we call lua_setglobal(lua, “test_function”); to assign the function an actual name that LUA script can use to call the function.

Well that’s about it. I have included the source code for the lua_test app which you can download from here

IwGame Engine v0.36 Released – XML Data bindings, Video, True Type Fonts and First 100% XOML Mark-up Driven Game

New here? What’s IwGame? IwGame is an open source free to use cross platform game and app engine for iPhone, iPad, Android, Bada, Playbook, Symbian, Windows Mobile, LG-TV, Windows and Mac, built on top of the Marmalade SDK. You can find out more and download the SDK from our IwGame Engine page.

Its been a while (again) since we last released an update for IwGame but 0.36 has finally landed. Our plans to make IwGame viable as an app development platform as well as game development platform continue to go ahead as you will see from this update. In particular the supoprt for true type fonts and XML data bindings

Below is the latest list of changes for IwGame 0.36:

  • IwGame can now be put into Open GL compatible mode, which allows mixing of raw GL with IwGame rendering
  • New variable type added called CIwGameXomlVariableXML. This variable type is used to store structured XML data. XML files can be loaded and assigned to an XML variable at which point they will be parsed into an XML tree which can be accessed later.
  • All action parameters can now take variables as parameters as well as values
  • Array variables have a new property called BindXML. BindXML will bind XML data to an array. The binding can pick specific tag / attributes out of XML data and bind it to the array. The format of BindXML is BindXML=”XML_Variable_Name:XML_Tag:XML_Attribute”
  • New File type added to XOML that allows loading, conversion and binding of generic local and remote files to variables
  • New LoadFile action added to XOML which enables files to be force loaded or replacement of an already loaded files data
  • New SetKeyFocus action added which allows you to switch which actor has key focus
  • New IwGameVideo added. Marmalade video play back wrapped up into CIwGameVideoPlayer. XOML also supports Video resource types (local and remote)
  • New UI control added called VideoOverlay. This UI control allows you to display a video located locally or remotely as a UI element. Supports AutoPlay, Volume, Repeat, OnStart, OnEnd, OnPause, OnResume events and control playback using command property
  • Support added to sprites and actors for an AlphaMode
  • Actors can now be conditionally loaded
  • Support added for true type fonts, located in resource groups, in local files or on a web server. Fonts that are generated from the same external font TTF file will re-use already downloaded TTF to save re-download
  • Support added to fonts for auto point size calculation based on max screen dimensions vs number of lines allowed on display when creating fonts from TTF’s
  • Fonts that are defined without preload will only be loaded when an actor that uses it is displayed.
  • Timelines are no longer stored in the resource system. They now have their own timelines manager. Actors and scenes have their own timelines manager and a global timeline manager is also available. This cuts down the noise in the main resource manager, makes resource and timeline searches faster and allows timelines to be declared local to an actor
  • Actions are no longer stored in the resource system. They now have their own actions manager. Actors and scenes have their own actions manager and a global actions manager is also available. This cuts down the noise in the main resource manager, makes resource and actions searches faster and allows actions to be declared local to an actor
  • System:9 added to check if pointer is available
  • Preset animations now resize to fit screen orientation changes
  • Labels now have an AutoHeight parameter that causes them to resize to fit the height of the text that they contain
  • UI components can now be marked as SizeToContent, which causes them to base their size on the content that they contain. Siznig can be locked to a specific axis using x, y, xy or none
  • OnKeyBack / OnKeyHome support added to UI actors
  • List Box now supports key navigation
  • Optimisations: Optimised scene and sprite systems to eliminate the thousands of allocs / deallocs every second in complex scenes (if you check metrics you will notice that free and malloc are being called like mad). Unfortunately this has meant limiting the range of layers for scenes to 10. Any scenes with a layer order of 10 or more will now be rendered after layers 0-9 and in no particular order
  • StackPanel now supports horizontal centering in horizontal orientation and vertical centering in vertical orientation
  • Actor brush can now be the target of an animation
  • Support added to actors for separate x and y position bindings / properties and animation targets
  • XOML variables can now be created conditionally
  • Image based actors / UI now support AspectLock property. This allows you to lock the aspect ratio of an actor that is sized using proportional sizing. For example, if you have an icon inside a horizontal stack panel who’s height is proportional to the size of the scene, ordinarily if you made the proportional size of the icon 50% on both axis, it would get stretched on the x-axis. By setting the AspectLock to the y axis, the height of the icon will be locked to 50% of the height of the stack panel, but the width of the icon will be calculated based on the size of the brush / src_rect that is used to represent the icon.
  • Pre-defined animations PA_ScrollOnFromLeft etc now only affect the relevant axis
  • Timeline has new TimeScale attribute which scales the rate at which animations within the timeline are played back. Actors also have a new target property called TimeScale, which can be used to adjust the TimeScale of the currently attached timeline (can be set via set property, bindings or animation target)
  • New wait_var_is_value command added to program system. This command will pause program execution until a variables value is a specified value
  • CIwGameString now has a Split method which splits a string into an array of strings using a specified separator
  • Images will no longer be converted to a default RGBA5551 format, if no format is specified. You can also set the format via code (must be set before calling Init())
  • Updated grid / list box controls to work with dynamic data
  • Condition variable operands can now be variables and condition variables can now use arrays
  • Inverse conditions are now available for all elements that use conditions by pre-pending the exclamation mark ‘!’ character to the front of the condition variable name
  • Animations now have categories
  • Added new extension modifier CIwGameModCollisionNotiify. If you attach this modifier to an actor and define OnCollisionBegin / OnCollisionEnd event handlers you can execute actions based on collision between different objects. A mask can also be provided when defining the modifier to allow masking of actors by type
  • Added new XMLGrid example app which shows how to bind XML data to a grid
  • Added ActorTest example (shows parent / child actors in XOML)
  • Added ActorTest2 example (shows many actors in XOML)
  • Added GameSceneGL example (shows how to mix raw Open GL with IwGame)
  • Added Game Of 10 example game (100% XOML driven)
  • BUG FIX: Grid auto column / row sizing was broken
  • BUG FIX: Fixed grid cell horizontal alignment. Also fixed grid resizing when orientation changes
  • BUG FIX: ListBox crashes when re-assigning a new array to an already existing ListBox
  • BUG FIX: When an action is declared in the scene and called from an actor event it wasn’t being found
  • BUG FIX: Fonts were not being searched for by name
  • BUG FIX: Sprites transform is now rebuilt when changing opacity from 0 to some other value
  • BUG FIX: Fixed many crashes related to duplicated resources
  • BUG FIX: Ad click not recognised when ads view not inside a scene
  • BUG FIX: Grid row horizontal alignment fixed
  • BUG FIX: Grid orientation change resizing fixed
  • BUG FIX: When a scene / actor is created it will now update its data bindings immediately after creation
  • BUG FIX: Can now set Background, SelectedBackground and DisabledBackground to NULL, which will remove the background image of the control

That’s quite a few changes, although there are quite a few bug fixes in there that will make some of you very happy. Lets take a look at some of the more notable changes:

100% XOML Mark-up Driven Development

We wanted something cool and different to show off for 0.36 so I spent some time over the weekend designing, creating and documenting a small game that is created using entirely in XOML mark-up and no C/C++ / script coding. I’m very pleased with the results and decided to include the game (GameOf10) with the 0.36 release as an example that others can use to try creating their own 100% XOML games and apps. If you do create any 100% XOML apps or games then please get in touch and let us know.

XML Data Bindings

Another new cool feature we have added to 0.36 is the ability to bind data directly parsed from a local or remote XML file to user interface components. This may not seem like a big deal but it is in the app development world and in some respects also in the game development world. Imagine if you will a vendor that wants an app that he / she can give away to customers that shows all of his / her very latest offers. Usually the vendor would need to add the new offers to his app, rebuild it and resubmit it to the app stores. Using XML bindings he / she no longer needs to do that. The vendor simply places the latest products into an XML file and uploads them to the shops web server. The vendor then creates some XOML UI to display the XML file and submits the app to the app stores. Users come along and download the app, the app pulls the vendors latest offers data from the server and displays all of the vendors offers in the app. The vendor has to do nothing else besides maintain his offers XML file. Nice eh? Well the vendor seems to think so because sales are up 🙂

This very same approach can be applied to game development and many developers already do just that, such as the famous Zygna games. You can store game content on a server and bind the data to your games UI / game objects. You can modify the game any time you like after release. Bugs? What bugs, I just modified my XML files and fixed them 🙂

So how to use this new cool feature?

Array variables have a new property called BindXML. BindXML will bind XML data to an array. The binding can pick specific tag / attributes out of XML data and bind it to the array. The format of BindXML is BindXML=”XML_Variable_Name:XML_Tag:XML_Attribute”. Lets look at an example:

[sourcecode language=”xml”]
<Variable Name="BookXML" Type="xml" />
<File Name="File3" Location="test1.xml" FileType="xml" Preload="true" Variable="BookXML" />
<Variable Name="GridItems1" Type="arraystring" BindXML="BookXML:Chapter:Brush" />
<Variable Name="GridItems2" Type="arraystring" BindXML="BookXML:Chapter:Name" />
<Variable Name="GridItems3" Type="arraystring" BindXML="BookXML:Chapter:Description" />
<Variable Name="GridItems4" Type="arraystring" BindXML="BookXML:Chapter:Pages" />
[/sourcecode]

In this example we create an XML variable then load the file test1.xml into BookXML. We then create 4 arrays and bding the Brush, Name, Description and Pages attributes of each Chapter tag to the arrays. Heres the example test1.xml file:

[sourcecode language=”xml”]
<Contents>
<Chapter Name="Chapter1" Description="This is chapter 1" Pages="10" Brush="Button1Brush" />
<Chapter Name="Chapter2" Description="This is chapter 2" Pages="12" Brush="Button2Brush" />
<Chapter Name="Chapter3" Description="This is chapter 3" Pages="11" Brush="Button1Brush" />
<Chapter Name="Chapter4" Description="This is chapter 4" Pages="5" Brush="Button12rush" />
<Chapter Name="Chapter5" Description="This is chapter 5" Pages="7" Brush="Button12rush" />
<Chapter Name="Chapter6" Description="This is chapter 6" Pages="9" Brush="Button1Brush" />
<Chapter Name="Chapter7" Description="This is chapter 7" Pages="2" Brush="Button12rush" />
<Chapter Name="Chapter8" Description="This is chapter 8" Pages="4" Brush="Button12rush" />
<Chapter Name="Chapter9" Description="This is chapter 9" Pages="6" Brush="Button1Brush" />
<Chapter Name="Chapter10" Description="This is chapter 10" Pages="16" Brush="Button1Brush" />
<Chapter Name="Chapter11" Description="This is chapter 11" Pages="16" Brush="Button2Brush" />
<Chapter Name="Chapter12" Description="This is chapter 12" Pages="16" Brush="Button2Brush" />
<Chapter Name="Chapter13" Description="This is chapter 13" Pages="16" Brush="Button1Brush" />
<Chapter Name="Chapter14" Description="This is chapter 14" Pages="16" Brush="Button1Brush" />
</Contents>
[/sourcecode]

Now we generate a grid to show the data:

[sourcecode language=”xml”]
<Template Name="GridItemTemp">
<Label Name="Grid1Item$index$" Size="-20, 90" Background="Button1Brush" BackgroundColour="200, 200, 200, 255" SelectedColour="200, 255, 200, 255" Font="trebuchet_12" GridPos="$gridpos$" HitTest="true" SelectType="toggle" Selected="false" />
</Template>
<Grid Name="ItemsGrid" Size="-100, -100" Background="PanelBrush" BackgroundColour="255, 255, 255, 255" HitTest="true" ClipMargin="10, 10, 10, 10" MultiSelect="false" SelectedIndex="5" UseParentOpacity="false">
<RowDefinition Name="r0" AlignV="middle" Height="100" />
<ColumnDefinition Name="c0" AlignH="left" Width="-20" ItemsData="GridItems1" ItemsTemplate="GridItemTemp" ItemsTargetType="background" />
<ColumnDefinition Name="c1" AlignH="left" Width="-20" ItemsData="GridItems2" ItemsTemplate="GridItemTemp" ItemsTargetType="text" />
<ColumnDefinition Name="c2" AlignH="left" Width="-40" ItemsData="GridItems3" ItemsTemplate="GridItemTemp" ItemsTargetType="text" />
<ColumnDefinition Name="c3" AlignH="left" Width="-20" ItemsData="GridItems4" ItemsTemplate="GridItemTemp" ItemsTargetType="text" />
</Grid>
[/sourcecode]

Video

A new sub-system called CIwGameVideoPlayer has been added that wraps the Marmalade SDK video playback code up into a nice and easy to use singleton called IW_GAME_VIDEO. We also have a new type called CIwGameVideo which represents a video resource that can be created in code or in XOML. Videos can be loaded from local storage or remotely from a web server either immediately or on-demand via the new VideoOverlay UI component. Lets take a quick look at an example:

[sourcecode language=”xml”]
<Video Name="Video1" Location="http://www.drmop.com/video1.mp4" Codec="MPEG4" />

<StackPanel Name="SP1" Size="300, -100" Background="PanelBrush" Orientation="vertical" AlignH="centre" AlignV="top" SizeToContent="none" >
<Label Background="Button2Brush" Size="-90, 100" SelectedColour="128, 255, 200, 128" Text="Option 1" Font="trebuchet_12" />
<Label Background="Button2Brush" Size="-90, 100" SelectedColour="128, 255, 200, 128" Text="Option 1" Font="trebuchet_12" />
<Label Background="Button2Brush" Size="-90, 100" SelectedColour="128, 255, 200, 128" Text="Option 1" Font="trebuchet_12" />
<Label Background="Button2Brush" Size="-90, 100" SelectedColour="128, 255, 200, 128" Text="Option 1" Font="trebuchet_12" />
<VideoOverlay Name="Vid1" Background="Button2Brush" SelectedColour="128, 255, 200, 128" Video="Video1" Size="-90, 100" AutoPlay="false" Volume="0.3" Repeat="1" AspectLock="x" OnEnd="VideoEnd" OnTapped="Play">
<Actions Name="VideoEnd">
<Action Method="HideActor" Param1="SP1" />
</Actions>
<Actions Name="Play">
<Action Method="SetProperty" Param1="Command" Param2="play" Param3="Vid1" />
</Actions>
</VideoOverlay>
<Icon Background="Button1Brush" />
</StackPanel>
[/sourcecode]

This example creates a video resource for a video file located on a web server. We then create a stack panel that contains 4 labels and a video overlay stacked on top of each other. The video is not loaded or played until the user taps on the space containing the video. When the video ends the whole UI will be hidden.

Now I don’t think you can ask for a simpler way of integrating video into your products 🙂

True Type Fonts

The font system has been reworked to add support for true-type fonts that are either located in a Marmalade resource group or located in a local or remote TTF file. Lets take a quick look at an example:

[sourcecode language=”xml”]
<Font Name="font1" Location="Serif.ttf" AutoPointSize="50" PointSize="0" Preload="true" />
<Font Name="smallfont1" Location="Serif.ttf" AutoPointSize="60" PointSize="0" Preload="true" />
[/sourcecode]

In this example, we create two different sized fonts from a local TTF file. We have the ability to auto generate the correct font point size based on the devices screen size. You simply specify how many lines of text you would like to fit onto the display using AutoPointSize. Note that PointSize will be added onto the calculated point size. Also note that, fonts will re-use font files to save having to reload / download them. For example, because font1 already loaded the Serif.ttf file, smallfont1 will re-use that same file.

OpenGL Compatibility

You can now freely mix Open GL with IwGame. A new example has been provided that shows how to mix Open GL with IwGame.

Action Variable Parameters

We have reworked the action parameter system to enable variables to passed as parameters as well as values. For example:

<Action Method=”SetProperty” Param1=”Timeline” Param2=”StillAnim” Param3=”SelectedCardNames:0″ />

This action assigns the “StillAnim” timeline to the actor whos name is stored as the first index in the SelectedCardNames array.

Conditions can now use inverse condition checking by pre-pending an exclamation mark ni front of the condition variable name, this saves having to create inverse conditions. For example, HasBullets becomes !HasBullets

Optimisations and Clean-up

We have reworked the actions and timeline systems to remove them from the resource system as the resource system can quickly become cluttered making searching for resources slower than it should be. A cool side affect of this change is that actors can now have their own local actions and timelines lists, reducing the chances of naming conflicts.

We have also gone through almost every line of code and removed the excessive use of memory allocation / deallocation that were occurring every frame.

New Collision Modifier Added

Added new extension modifier CIwGameModCollisionNotiify. If you attach this modifier to an actor and define OnCollisionStart / OnCollisionEnd event handlers you can execute actions based on collision between different objects. A mask can also be provided when defining the modifier to allow masking of actors by type

There are also a ton of other changes such as Labels that now size to the text they contain and UI elements can be told to size to their content

Well that’s it for this update. We’ve just started looking into LUA integration as well as creating TileMaps. Hopefully those features will make it into IwGame 0.37.

New IwGame Engine Game – CandyMare

Hey everyone, Developer Noisy Ninja has just released their new FREE awesome IwGame Engine powered game CandyMare for Android on Google Play – https://play.google.com/store/apps/details?id=com.noisyninja.candymare

Heres some info about CandyMare:

Joey had too many candies and is having nightmares, guide him through insane puzzles with ghosts and monsters blocking his way to the candy factory.

• Optional ad removal in-app purchase.
• Teleport your way out of a tough spot.
• Avoid deadly hallucinating mushrooms.
• Collect all 3 stars per level.
• Track your achivements.
• 3 chapters and 60 levels of candy adventure.
• A puzzle unlike any you have played before.
• More chapters, crazy levels and new powerups coming soon!

Best of luck to Noisy Ninja

NB. Please help to support the IwGame Engine and its developers by downloading and rating each others apps.

IwGame – How to mix raw Open GL with IwGame Scenes

A fellow developer recently had the need to mix raw Open GL with IwGame scenes so I decided to take a look into the matter. The problem with mixing the Marmalade SDK’s graphics sub systems IwGx and Iw2D with raw Openm GL is two fold:

  • Marmalade’s IwGxClear() / Iw2DSurfaceClear() functions seem to do something internally that prevents the display of Open GL rendering code. I believe that the actual underlying call to clear the screen is called when IwGxFlush() gets called so any Open GL rendering carried out during the frame is wiped out as soon as IwGxFlush() is hit.
  • IwGx / Iw2D rendering is deferred until either IwGxFlush() or Iw2DSurfaceShow() is called. This means that anything you draw using Open GL during the frame will be drawn over when the flush is done at the end of the frame because Marmalade does all its rendering when the flush occurs

Ok, problem 1 is easy to fix. We’ve added a new property to CIwGame called GLCompatible. If you have any scenes in your app that need to render using raw Open GL then call GAME->setGLCompatible(true) to force IwGame to clear the display buffer using Open GL instead of IwGx. (You will need to download http://www.drmop.com/wp-content/uploads/2012/06/GameSceneGLTest.zip and use the new IwGame that is contained in the archive to use this new feature.

Problem 2 is also easy to fix. In the scene that you call raw Open GL rendering code, call IwGxFlush() before you begin rendering using Open GL. This will force Marmalade to draw everything that’s waiting to be drawn. As IwGx is built upon Open GL you should also NOT rely on GL to be in the state that you left it in previous frame, so ensure that you restore matrices, shade model and any other GL specifics that IwGx may have modified.

You can download an example that shows the complex UI example with a GL scene on top. The GL scene also contains a stack panel that shows that you can also add IwGame stuff on top of GL rendering. The example is located at http://www.drmop.com/wp-content/uploads/2012/06/GameSceneGLTest.zip

New Marmalade SDK FAQ

I trawl the Marmalade SDK forums from time to time and I see many questions that come up from time to time. In an attempt to answer those questions and cut down Marmalade forum traffic I have started a Marmalade SDK FAQ that should hopefully help fellow Marmalade developers find answers to commonly asked questions without having to wait for forum responders or search high and low through the SDK documentation / web.

The new FAQ is located at http://www.drmop.com/index.php/marmalade-sdk-faq/

It is also available in a more compact and readable PDF format from http://www.drmop.com/Marmalade_SDK_FAQ.pdf

IwGame Engine v0.35 Released – Multi-touch User Interface, XOML Programs, 9-Patch Rendering and Arrays

New here? What’s IwGame? IwGame is an open source free to use cross platform game engine for iPhone, iPad, Android, Bada, Playbook, Symbian, Windows Mobile, LG-TV, Windows and Mac, built on top of the Marmalade SDK. You can find out more and download the SDK from our IwGame Engine page.

Its been a while since we last released an update for IwGame but 0.35 is finally here. Our plan for this update was to enabled IwGame as a viable app development SDK as well as game development. With the new addition of the user interface we feel that we have made a great stride towards that aim.

Here is the latest list of changes:

IwGame 0.35 Changes:
* XOML schema added. This enables error checking, intellisense and auto completion when creating XOML
* New user interface system added, enabling IwGame as an app developemnt platform. IwGameUI has the following features
* Static and proprtional sizing an margins
* Buttons / toggle / sticky buttons with OnToggledOn and OnToggledOff events
* Labels
* Text input boxes
* Sliders (horizontal and vertical)
* Canvas – Allows organisation of content on a large scrollable canvas area as well as docking of content to edges
* Stack panels and wrap panels (horizontal and vertical) allow organisation of content in vertical and horizontal stacks
* Wrap panel (horizontal and vertical), works much in the same way as an orinary stack panel exceot content that overflows the edge of the panel will wrap down to the next line or across to the next column
* Listbox (horizontal and vertical) allows organisation and selection of content using sigle and multi-select. Can use templates and bindings for automatic binding of data to the list box
* Grid allows the display and navigation of two dimensional data, each column or the whole grid can be bound to data and templates.
* Image view that allows the display and navigation of large images (supports panning and pinch zoom), can also contain any other UI or actor
* Text view that allows the display and navigation of text (supports panning and pinch zoom)
* Web view – A wrapper for Marmalades Web API. Multiple web views cn abe instantiated inside the UI
* TabBar (horizontal and vertical) – A tab bar allows the display of multiple pages or views of content. The tab bar can be orientated horizontally or vertically. Tab bar can appear at top, bottom, left or right of control area. View swicthing can also be animated using a selection of preset animations or using your own custom animations.
* All UI elements are supported in XOML, fully bindable and integrates directly into all other systrems including the animation system.
* Container UI elements will clip children. Container actors also allow the specification of a clip margin.
* Scrolling and zooming supports iOS style spring effect to place contents back into position when going over boundaries
* All UI elements support hide and show timelines
* Rendering system now supports 9-patch rendering using 9-patch brushes
* Sprite system now supports 4 parameter skewing
* IwGameInput system reworked to make it more multi-touch friendly
* XOML now fully supports multi-touch events (up to 5 simultaneous events)
* Event bubbling added, enabling touch events to travel up to parent actors
* Actors and scenes now support proportional sizing
* Actors now support margins and docking to screen edges
* Actor touch events now provide the touch index that causes the event
* Sprites / actors can now scale their opacity by their parents
* Delta animations targeting position, scale, rotation, colour and opacity will apply the update from the original value that was assigned to the actor
* Actors now support simple bindings. Simple bindings are a simple binding of a variable to an actors property without having to create a full bindings list
* Actors can now be created from a brush. Using brushes instead of images, allows you to create image based actors without having specify a visual size
* Scenes and actors now support dynamic resizing and orientation changes
* Support for array variables added
* System XOML variable array added. Allows you to query current display width, height, mode, device type, multi-touch / compass, accelerometer, keyboard support. Also provides a rating hint as to the size of the display, which you can be used to determine size of fonts etc
* New program / command system added, This new system is a very powerful way of creating game or app flow logic in XOML
* New DebugText action that displays the value of a XOML variable / text to the debug output
* New ChangeProgram action that allows the modification of running programs
* New CIwGameAnimUtil class added that enables creation o simple timelines in code
* Images now support filtering and format conversion in code and in XOML
* CIwGameRender2d now supports rendering of images fom short vectors. These types of images will not use the data cache
* Actor / sprite rendering optimised to cut down processing of actors / sprites not on screen or visible
* Sprite system completely changed to support heirarchical rendering
* Text rendering optimised when not rotated
* Fonts, images and XOML files can now be conditionally loaded
* Scene FixedAspect and LockWIdth have been deprecated. Scenes now use the new CanvasFit option which supports canvas fitting to Width, Height, Both, None and Best Fit
* Physics can be disabled for a complete scene to reduce processing
* IwGame class now uses layer ordering to determine priority of touch events
* Re-arranged XOML tags and tag attributes, placing more commonly used tags / attributes earlier to speed up XOML parsing
* Touch focus is now released when user touches an actor and moves their finger away from the actor by more than double the radius. Touch focus is also released when camera is panned in scenes that have touch panning enabled.
* Frame rate cap has been removed
* BUG FIX: When releasing scene touch panning on an actor it no longer takes it as a tap on the actor
* BUG FIX: Mip-mapping globally disabled as it was causnig many rendering artefect issues
* BUG FIX: camera touch pan scaling, camera pan now follows finger accurately
* BUG FIX: Attempting to instantiate a template inside an actor crashed has now been fixed
* BUG FIX: Fixed issue with bool variable add method
* BUG FIX: CIwGameActor::setAngularVelocityDamping() fixed
* BUG FIX: Fixed issue where releasing a scene touch pan on an actor will send the OnBeginTouch event to the actor

As you can see that’s an immense bunch of changes. if you have been following the real-time updates in the forum then you will probably be aware of many of these changes: I can tell you one thing for sure, I did not enjoy updating the documentation

Lets take a more in-depth look at some of these new changes:

User Interface

The biggest change in 0.35 is the additional of the user interface system IwGameUI. Our aim was to create a user interface system that was good for both app and game development. With this aim in mind we believe we have created a user interface system that is better, more versatile and more extensible than currently available user interface systems.

Here are the main features of IwGameUI:

  • Data binding (two way in some cases). Data binding allows you to map XOML variables / arrays to UI elements and when those variables change the changes are reflected in the user interface components
  • 14 different kinds of controls (buttons, icons, labels, text boxes, list boxes, grids, sliders, canvas, stack panels, wrap panels, image views, text views, web views and tab bars)
  • Support for events and actions, such as handling button toggling, selection and value changes.
  • Fully integrated into IwGame’s animation system
  • Styling and templating
  • 9-patch rendering which allows you to render clean looking buttons / borders without losing resolution
  • Supports modifiers and other customisations, allowing you to augment the behaviour of UI elements
  • Supports proportional sizing
  • Supports dynamic orientation / screen size changes
Ywo example projects have been included with 0.35 that show a basic UI and a cmoplex UI. Yuo can see a video of the complex UI at http://www.youtube.com/watch?v=ZImWhKwV1tA

Heres a quick example of a little bit of UI defined in XOML:
[sourcecode language=”xml”]
<StackPanel Background="PanelBrush" Orientation="horizontal" Size="-95, 100" AlignV="middle" Margin="0, 0, 10, 10">
<Icon Background="Button1Brush" Margin="20, 0, 0, 0" />
<Icon Background="Button2Brush" Margin="20, 0, 0, 0" />
<Icon Background="Button3Brush" Margin="20, 0, 0, 0" />
<Icon Background="Button4Brush" Margin="20, 0, 0, 0" />
</StackPanel>
[/sourcecode]

This bit of XOML will create a stack panel that contains 4 icons stacked horizontally at the side of each other. Notice that the width of the stack panel is set to –95. The new negative sizes represent proportional sizing, with –95 meaning either 95% of the parents container size or if no parent, 95% of the screen size.

Programs and Commands

Whilst the events / actions system is great for handling the event based parts of your game we felt that we needed a new system that would allow some kind of game / app logic scripting that would enable developers to define sets of complex functionality that can be ran at any point during the apps lifetime. Obviously as we are programmers we felt a program / command style system would feel most natural. We also felt that we needed a versatile system that the developer could completely customise to suite their needs, so we added the program system. IwGame’s program system allows developers to create complex programs from a list of hierarchical commands. Commands are executed in the order in which they are declared until the end of the program is reached. Commands can also executed concurrently, allowing the program to run multiple commands together each frame. Lets take a look at a quick program example:
[sourcecode language=”xml”]
<Program Name="Main" AutoRun="true" Priority="true">
<Command Parallel="true">
<Command Method="show_video" Param1="IntroVideo" />
<Command Method="run_actions" Param1="StartAnimation" Param2="Door" />
</Command>
<Command Method="show_speech" Param1="0" Param2="Hey how ya doing?" />
<Command Method="show_speech" Param1="0" Param2="Tap that door" />
<Command Method="wait_tapped" Param1="Door" />
<Command Method="set_property" Param1="Timeline" Param2="RemoveItemAnim" Param3="Door" />
<Command Method="wait_tapped" Param1="ID Card" /> <Command Method="add_inventory" Param1="ID Card" />
<Command Method="load_scene" Param1="Scene2.xml" />
</Program>
[/sourcecode]

We define a program named “Main” and tell I to automatically run when the scene is loaded. We set the program as a priority program, which means it is executed before all other programs.

Next we add a command that executes two other commands in parallel. This will show an intro video and start a door animation. Once complete the player will be shown the “Hey how ya doing” speech and so on and so forth.

As you can see using the program system it becomes an incredibly easy process to define complex logical game and app flow.

Multi-touch in XOML

XOML now supports multi-touch events for actors. Actors can now respond to up to 5 simultaneous taps, begin and end touches. For example, you could control 5 actors at the same time on screen in a game, or create a cool user interface element that utilises more than one finger, like we have done with pinch zoom image and text view controls.

Proportional Sizing, Docking, 9-Patch Brushes and Orientation Changes

We now support proportional sizing of actors and margins, allowing you to create game and app layouts that are completely screen size independent. Actors can now be docked to the edges of the screen and canvas containers. 9-Patch brushes now allow the rendering of images where you want to retain the clean 1:1 pixel border around an image. All actors and scenes can now detect and handle orientation changes. Any actors or UI elements that are declared as proportionally sized will automatically be resized for you when the screen resolution changes. In addition, if no size is specified when creating an actor the actors assigned brush size will be taken as its visual size. We recommend that you create all actors from brushes to take full advantage this feature.

Array Variables, System Variables and Simple Bindings

XOML now supports the creation and definition of array variables. The bindings system also works with the array system. To access a particular element of an array to a property you would use variable_name:array_index, instead of simply variable_name.

A new system array has been added by default to the XOML system. This allows you to query certain aspects of the system such as display size, support for multi-touch etc..

Actors can also use simple bindings. A simple binding is a binding without a bindings collection which allows you to bind a single variable to a single actor property, e.g:

<ActorText Name="NameLabel" ......... Binding="[Text]ProfileName:2" />

In the above example we bind the 3rd index of the ProfileName array to the Text property of NameLabel.

Event Bubbling

Actors now support bubbling of touch events. Actors can be marked to receive input events from their child actors

Actor and sprite optimisations

We have gone through and optimised the actor and sprite systems to cut down a lot of rendering and processing of actors / sprites that are clipped or off screen.

Scene Virtual Canvas Sizing

We have changed the way a scenes canvas sizing is set-up to make it more versatile. You can now choose the method by which iwGame scales your scenes to the final display as well as choose the scenes origin

Image filtering and format conversion

When images are declared in XOML you can now specify if they should be filtered when rendered. You can also specify the format that you would like the image to be converted to before uploaded to texture RAM, reducing the size of your texture RAM usage.

Licensing Terms Updated

The licensing terms for IwGame Engine usage has been changed. Whilst there are other minor changes, the main change is:

You may not use the IwGame Engine or any of its parts to create products that can be used to create other apps and games for mobile devices without express prior written notice from an executive of Pocketeers Limited with the correct authority to grant authorisation.

Marmalade SDK 6.0.2 Released

Marmalade have just released 6.0.2 of their awesome SDK. Looking at the change list there are some very welcome bug fixes:

  • Exporters: Added support for Maya 2013 and Max 2012
  • iOS: touches are no longer passed to the surface below the web view
  • iOS: s3eOSReadString now handles split keyboards correctly
  • iOS: added s3eEdkAppGetInitialOpenURL to get the initial open URL
  • android: fixed icf splash screens when fixing rotation
  • playbook: s3eOSReadString now cancels properly
  • IwHTTP: fixed to work without threads
  • Added menu options to Windows simulator for Retina display
  • OSX: fixed to make building extensions possible
  • Android splash fixed when using dispfixrot=2
  • android: building of EDK modules
  • ios: WebView orientation (IwGX and s3eWebView) on iPad
  • android: fixed crash with image property in CImagePtr when loading a png file

There is however a crash issue with Bada builds

Marmalade Job Post – Playalla Need Word Game Developer

Hi Everyone,

Another job posting has come across my desk recently so here it is. A new start-up called Playalla is seeking a  C/C++ Marmalade SDK developer for a short term contract (around 3 months) to help them finish their word games. Playalla already have a prototype of their game up and running based on match-3 game play. Ideally they are looking for a developer that has previous experience with creating word games. The work can be carried out remotely so is ideal for a freelance game developer.

If you are interested then please send a few details about yuorself, your experience (games released etc..) to Wissam at wissamharoun@hotmail.com

Mat