IwGame Engine v0.31 Released – Facebook and Full cOnnecticOns Source Available

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 tough week, my Apple Mac blew a gasket and refused to boot. Didn’t know this until I had spent 4 hours trying to make the Mac boot from Snow Leopard, but you cannot boot a Mac Mini from any version of the OS other than the original version that came with the Mac! Arrrgggghhhhh, insanity! In the end I turned my office and house upside down to find the original Mac disk.

Finally got cOnnecticOns cleaned up and submitted to the app stores. I also added 10 more levels and a game editor that allows players to create up to 20 of their own levels on-device and play them. I plan to allow sharing of these custom levels in a future version. We also added Facebook posting to IwGame and therefore has now been added to cOnnecticOns. You can find our more info about the game at http://appliter.com/apps/connecticons/connecticons.aspx

Ok, onto the update. IwGame v0.31 is kind of a special release because it contains the FULL source and assets of the game that you will see on Android Market and very soon Blackberry App World, Apple iTunes and SamsungApps for Bada.

Here’s the full list of changes for 0.31:

IwGame 0.31 Changes:

  • cOnnecticOns full commercial game with source and assets provided as an example of engine usage
  • CIwGameFacebook added – Currently provides login and wall posting access
  • New AddVariable action added which allows you to add a positive or negative value to a XOML variable with limits
  • New EnterValue action added that brings up the devices keyboard allowing the user to enter a value into a XOML variable
  • New UpdateText action added will update a text actor with the value of a variable
  • New Exit action added that allows the user to exit the game
  • 3rd paramater added to XOML actions
  • DoSleep added to CIwGameBox2dWorld to enable / disable object sleeping, also added to scene XOM
  • IIwGameXomlResource now has an actual type, allowing type checking for exact object types
  • OnKeyBack and OnKeyMenu events added to scene and XOML. These fire when back and menu keys are pressed
  • BUG FIX: CIwGameSprite position and origin now 32 bit vectors, which helps prevent positions overflowing
  • BUG FIX: When a scene is destroyed and it has touch focus it was causing a crash
  • BUG FIX: If a scene becomes inactive or invisible it now loses touch focus
  • BUG FIX: Velocity / angular velocity now applied when actors have no physics attached
  • BUG FIX: JPEG image data is now correctly converted from BGR to RGB
  • BUG FIX: CIwGameString, find index now properly reset

As well as the release of the full source for cOnnecticOns, we also snook a few extra col bits and bobs in there.

New CIwGameFacebook Class

The main purpose of this class is to allow the user to log into facebook and interact with it. Right know, only logging in and wall posting functionality is provided using the following method:

bool PostWall(const char* message, const char* link_uri, const char* image_uri, const char* name, const char* description);
  • message – Message to display to the users wall visitors
  • link_uri – URL that the user will visit when clicking on the wall post link
  • image_uri – URL of an image that you would like to be displayed along with the post
  • name – The title of the post
  • description – Description of the post (displayed in weaker font beneath title)

A Facebook wall post will look something like this:

Post to Facebook example

POst to Facebook Example

New XOML Actions

It is now possible to add a value onto an existing XOML variable using the new AddVariable action. You can also update a text actor with the value of a variable in XOML. Here’s an example showing how the editor in cOnnecticOns uses both actions together to create an up / down UI element that the player can use to change the number of cOnnecticOns available in the level:

        <!-- Create change connecticons buttons -->
        <InertActor Name="ConnectButton2" Position="0, -200" Size="81, 84" SrcRect="555, 482, 81, 84" Image="sprites1">
            <ActorText Name="ConnectButton" Depth="0" Font="trebuchet_12" Rect="-100, -50, 200, 100" Colour="0, 0, 0, 255" Text="2" />
            <InertActor Name="DownButton" Position="-60, 0" Angle="-90" Size="48, 51" SrcRect="868, 299, 48, 51" Image="sprites1" Depth="0" OnBeginTouch="DownBeginTouch" OnEndTouch="DownEndTouch" OnTapped="DownTapped">
                <Actions Name="DownBeginTouch">
                    <Action Method="SetTimeline" Param1="buttonin4_anim" />
                    <Action Method="PlaySound" Param1="ui_tap" />
                <Actions Name="DownEndTouch">
                    <Action Method="SetTimeline" Param1="buttonout4_anim" />
                <Actions Name="DownTapped">
                    <Action Method="AddVar" Param1="EditorConnecticons" Param2="-1" Param3="0" />
                    <Action Method="UpdateText" Param1="ConnectButton" Param2="EditorConnecticons" />
            <InertActor Name="UpButton" Position="60, 0" Angle="90" Size="48, 51" SrcRect="868, 299, 48, 51" Image="sprites1" Depth="0" OnBeginTouch="UpBeginTouch" OnEndTouch="UpEndTouch" OnTapped="UpTapped">
                <Actions Name="UpBeginTouch">
                    <Action Method="SetTimeline" Param1="buttonin5_anim" />
                    <Action Method="PlaySound" Param1="ui_tap" />
                <Actions Name="UpEndTouch">
                    <Action Method="SetTimeline" Param1="buttonout5_anim" />
                <Actions Name="UpTapped">
                    <Action Method="AddVar" Param1="EditorConnecticons" Param2="1" Param3="10" />
                    <Action Method="UpdateText" Param1="ConnectButton" Param2="EditorConnecticons" />

The mark-up marked in red show the new AddVar and UpdateText XOML actions.

Basically when the user taps the DownButton actor the OnTapped event fires which calls the DownBeginTouch actions list. This actions list contains two actions:

AddVar – This adds -1 onto the EditorConnecticons variable and limits it to 0, so it does not go below 0.
UpdateText – The next action copies the value of the EditorConnecticons variable into the ConnectButton text actor, which updates the number of connecticons on screen.

Support for Android Back and Menu Buttons in XOML

It is now possible to attach actions in XOML to the menu and back button events in a scene by handling the OnKeyBack and OnKeyMenu events. Note that only the current scene will handle button events.

Text Input via XOML

Using the new EnterValue XOML tag you can bring up the device keyboard and allow the user to input some text into a XOML variable.


As previously mentioned the full source to cOnnecticOns has been provided to enable developers to see a real working commercial game utilising IwGame. The first thing you will notice when looking at the code base is just how little code is actually there. This is because much of the mundane functionality such as creating layouts, handling events, creating animations, scenes etc.. are all handled by XOML. Please note that the supplied XOML is not optimised in way shape or form, in fact I have done many things long hand so as not to make the scripts convoluted and difficult to understand. When creating your own XOML you should probably focus more on re-use with templates, styles and global actions / animations etc..

Here is a brief overview of the provided XOML scripts:

  • Actors – This file contains physics materials, shapes and game object templates
  • Common – Contains common styles, animations and actions that are used across many scenes
  • ConfirmDialog – This is the dialog box scene for the rest scores action, it is displayed to the user when they attempt to reset their records
  • EditLevelSelect – Level selection screen that allows the user to select a custom level to edit
  • Editor – The level editor scenes
  • GameComplete – Shown to the player when they complete all zones and all rounds
  • Help – The basic help dialog that is accessible from the main menu
  • HUD – The in-game HUD that displays the scores and game buttons
  • Intro – The IwGame intro that is displayed at game boot
  • LevelCleared – The end of level score dialog that is displayed when the user completed or fails a round
  • LevelSelect – Level selection screen that allows the user to select a level to play
  • LevelSelect2 – Level selection screen that allows the user to play a custom level to play
  • Menu – The main front-end menu scenes
  • PauseMenu – The in-game pause men scene
  • ZoneLocked – Dialog scene that is displayed when the player finishes round 10 but has not unlocked all levels in the zone
  • ZoneSelect – Zone selection scene
  • Scenes 1 to 30 – Game level scenes
  • Scenes 101-120 – Custom blank level scenes

Note that some files contain more than one scene. For example, each game level file contains the pause menu, the main game level scene as well as the in-game HUD. The pause menu and HUD exist as separate XOML files so they can be re-used across all levels.

The code base contains implementations of the following custom scenes:

  • EditScene – Level editor scene, contains level editor logic
  • GameScene – A game level scene, contains game logic
  • LevelSelectScene – Custom scene for level select that handles updating of the scores in the level screen
  • ZoneSelectScene – Custom scene for zone select that handles updating of the lock / unlocked status of each zone

The following custom actors are also used:

  • ConnectActor – An actor that connect two bugs together with minimal logic
  • CounterActor – This is the main bug actor (originally called counters), handles all bug logic / collision etc
  • FloaterActor – Handles floating / fading text
  • GravityPlacerActor – Special actor that can be modified to change gravity within the editor
  • InertActor – Basically an actor that doesn’t much other than display itself
  • PlacerActor – A basic placeable object, used to position actors in the editor
  • SelectorActor – A basic selector actor used by the editor object selection screen to select which object to place

The rest of the code is pretty bog standard stuff. Game is the implementation of CIwGame and contains initialisation and shut down. Probably the most interesting part is where the custom XOML classes and events are added using the following code:

	// Add custom classes to XOML system
	IW_GAME_XOML->addClass(new InertActorCreator());
	IW_GAME_XOML->addClass(new GameSceneCreator());
	IW_GAME_XOML->addClass(new LevelSelectSceneCreator());
	IW_GAME_XOML->addClass(new ZoneSelectSceneCreator());
	IW_GAME_XOML->addClass(new CounterActorCreator());
	IW_GAME_XOML->addClass(new PlacerActorCreator());
	IW_GAME_XOML->addClass(new GravityPlacerActorCreator());
	IW_GAME_XOML->addClass(new SelectorActorCreator());
	IW_GAME_XOML->addClass(new EditSceneCreator());

	// Add custom game actions to XOML system
	for (int t = 0; t < CIwGameXomlAction_Global::Action_Max; t++)
 		IW_GAME_XOML->addAction(new GameXomlAction_Global((GameXomlAction_Global::ActionType)t));

These custom actions and events allow us to tie our game logic much closer to our XOML code.

Well that’s it for this update. We were aiming to get conditional XOML actions in for 0.31, but unfortunately it didn’t make it, but should do for 0.32.

24 thoughts on “IwGame Engine v0.31 Released – Facebook and Full cOnnecticOns Source Available

  1. Alsenitd says:

    Thanks for the update and Connections Source Code. It sure will help a lot of developers like me that want to start creating games.

  2. spec says:

    Hello, Facebook class surely is handy 🙂
    Was trying to get a tiled map up, but when i change to different screen sizes i get black borders around the tiles, i think its related with the filtering mode. Is this a known issue?


  3. drmop says:

    Could you send me a screen shot? I will take a look tomorrow.

  4. spec says:

    Sure, here you have the non-scaled version : http://i42.tinypic.com/ehzzp4.jpg
    and here the scaled one: http://i40.tinypic.com/pucmc.jpg

    I’am really think is related with filtering mode, i just have no idea on how to change it. Searched on marmalade forums, and it was supposedly going to be fixed on Iw2D at least one year ago.


  5. drmop says:

    If you take a look at IwGameRender2d.cpp methods DrawImage() and BatchDrawPrims() you will notice these two lines:


    If you have a play around with enabling / disabling those and let me know if it resolves the issue

    Oh, I’ve also noticed that the Windows build has odd rendering issues now and again but the problems don’t appear on device.

  6. spec says:

    Hello, while i was waiting for your answer i have been playing around and noticed that extruding the tiles by one 1px that problem was solved. Actually i got exactly the same result by changing
    mat->SetFiltering(filter); – > mat->SetFiltering(false);
    , so it was indeed related with filtering, changing the clamping flag had no positive or negative effect. The first solution (extruding) may be a good solution for people that need the filtering for quality, for me it makes no difference so i will just disable filtering, does IwGame have some public option for this?

    Now another issue appeared, common in both the solutions: http://i44.tinypic.com/25su795.jpg

    That black stripe is related to the camera position, if we move the camera around it changes places, sometimes disappear and sometimes are a bunch of them. I bet it’s related with arithmetic precision and rounding’s. It doesn’t seems to happen on scale up, only on scale down. I haven’t tried it on a smaller device, but will ask a friend today, although i have seen this issue before on another platform, and it was indeed related to precision, we fixed it by using some clamping. Here i’am completely lost…

  7. spec says:

    I uploaded a video so you can better notice the effect :http://www.youtube.com/watch?v=F0bDA-BP1iI

  8. drmop says:

    At the moment DrawImage() and BatchDrawPrims() accept a filter parameter that defaults to true. There is no provision in the sprite / actor / scene system to enable / disable filtering. I will add a method to switch filtering on and off on a per sprite manager / scene basis. Will stick this on the to do list. I can’t help thinking that this can be fixed using UV coordinates however, unless it is some kind of bug in the filtering system. I will look into it when I get some free time next week.

    I do feel that the black line issue is something to do with the Windows simulator, but that said the rendering engine has recently been upgraded to support sub pixel accuracy, so I suppose some up / down rounding errors could be creeping in. rest assured I will look into it, if you also get the same issues on hardware.

  9. spec says:

    Unfortunately the issue persists on a physical device. Actually it gets worst with also horizontal lines at random places :/
    When i was coding just on android i also got this problem and i was able to fix it by rounding the camera position to int values before calculating the transformation matrix. But here it’s not making any difference and its way over my head…

  10. drmop says:

    Can you by any chance send me your test project?

  11. spec says:

    Sure, here you go: http://www.4shared.com/zip/qrVvZXtl , Just replace the IwGame path on the mkf, and scale down/up from the default 800×480.


  12. drmop says:

    Fixed the issue. If you edit CIwGameSprite method RebuildUVList() and change lines 202,203 from:

    int px = 1;
    int py = 1;

    To the following:

    int px = (IW_GEOM_ONE / w) >> 1;
    int py = (IW_GEOM_ONE / h) >> 1;

  13. drmop says:

    Hmm, just tested it on simulator at 480×320 and the issue returns. Just going to check on hardware

  14. spec says:

    Wow that is amazing, you really know your way around the code :)!

    You are on the right track, that solved everything when we are using only one tile. Unfortunately when we add more than one it starts doing it again: http://www.4shared.com/zip/qdjuEBcM .
    I guess it must be related with the previous issue.. Btw have you considered transforming IwGame into some kind of paid product? I surely won’t mind to pay a license for a product with this kind of support..


  15. spec says:

    Humm i missed your last post. I actually haven’t tested it on a device either, so maybe the issues on the last project i posted are on the simulator… You may want to not loose time on it until i try running on a real 480×320 device. Later today i will have access to one and will post results for you.


  16. drmop says:

    Checked it out on hardware 480×320 and the same issue occurs. I believe that the issue is caused by integer math rounding errors, The right hand side of one tile is not at the exact same position as the left hand side of the next tile and because of sub-pixel rendering a small gap appears. The ideal solution would be to write a custom sprite / actor that acts as a tile map using shared vertices (this is on our to do list, but I will move it up the list of priorities, maybe even swap it round with in-app purchasing)

    We will also take a look at some way of disabling sub-pixel rendering

    We thought about making IwGame a paid SDK as we would like to put more people to work on it (At this moment its just me keeping it updated) but we would prefer that everyone has free access to it. In addition, developers already have to pay a license for Marmalade so it seems a bit unfair to charge them twice. We do offer paid support though, but there’s not really much call for it at the moment (the engine’s still trying to find its feet in the community)

    I’m happy to say that we have 200 developers downloading the SDK updates regularly now which is a bit of a buzz for us to be honest.

  17. spec says:

    I see, well i’am glad to know that a solution is on it’s way! It will be a real lifesaver for me, i just don’t know how the rest of the community prefer that over the “in-app purchasing”.

    Well maybe it’s unfair to developers paying for Marmalade and then for IwGame, but the way i see it, it’s also unfair that you guys receive depending solely on donations. I mean IwGame is a great product and i bet it will get better in the future, but that takes time and effort…
    Anyway congrats, 200 active developers is great, but i am sure that number will also raise greatly on the times to come. At some point maybe you guys could try some kind of deal with Marmalade team, for a “package” price or partners or something..

    Thank you for your help. Cheers.

  18. drmop says:

    Ok, finally sorted it. If you edit CIwGameSprite again and add the following two lines to TransformVertices at line 138:

    FinalTransform.t.x &= 0xfffffff8;
    FinalTransform.t.y &= 0xfffffff8;

    Now there’s a good fix in there I will leave the tile map actor for the moment.

    When we decided to start IwGame we initially did it to a) Help promote Marmalade (we felt the biggest thing missing from Marmalade was a solid game engine) and b) Create an engine that we could use to rapidly produce games (hence the inclusion of XOML). The next step was to produce a game editor, but unfortunately a lot of our time is taken up by other projects (food on the table and all that). I’m sure we will eventually get round to creating the editor eventually though, but for the moment I would rather see the engine support in-app purchasing and 3D and more game specific stuff such as tile / zone maps, AI path finding etc (our to do list is immense and always growing :D)

    Our primary mission with the engine is for a developer to think “Hmm, I need to do this” then take a look at the docs to find that its already implemented and ready to use. Our secondary mission is to make using Marmalade out-of-the-box much easier. We do hide a lot of the Marmalade functionality in IwGame but that’s just to enable a more rapid game production pipeline

    We have a good relationship with Marmalade and I’m not sure how they would feel about working more closely with the engine to be honest.

    Oh, thanks for reporting this bug by the way (well it actually turned out to be two bugs). Everyone will see the benefit when we released 0.32.

  19. spec says:

    Hehe, you rock!
    “(food on the table and all that)” exactly what i meant… 🙂

    At line 764 in IwGameActor.cpp there may may be a “copy-paste” error:
    if (name_hash == CIwGameXomlNames::CollisionSize_Hash)

    I also noticed that when using templates you do a tolower to the atributes names when we define an “instance” of the template, but don’t do it on the attributes of the actual template (it may be the other way around) i spent some time around it until i found what was the problem, at the moment i’am naming all the attributes in lower case, but camel case naming is useful for human reading, it would be great if you could do the tolower when parsing both places.

    No need to thank, it’s the least i can do really, plus i’am also interested on have it fixed 🙂


  20. spec says:

    It’s lines 746/747 and not 764, sorry…

  21. drmop says:

    Ah, oops, must have been one of my midnight copy and paste moments. It should be GetValueAsInt(), will fix that at this end. Cheers for finding that.

    I will put making the markers in the template lower case on the to do list.

  22. Martin says:

    Look like you forgot to handle the alignment in the ActorText loadfromxoml method.
    these lines should be added @1347:

    Thanks for the great engine !!

  23. drmop says:

    Nice one, thanks, added the fix at this end

  24. Gastel says:

    Hi drmop,
    just wanted to drop a line about how incredibly well done is IwGame. I’m a professional programmer working in the industry for over 20 years (my first published titles are for the Commodore 64). I’ve worked on “next generation” AAA titles and also on games for mobile/handheld devices. Recently I’ve been assigned to a cross platform “casual” game and after some researches I’ve choosen Marmalade as our SDK since my background is strongly “technical” and I can’t stand to the new and trendy “visual” SDKs and engines that are more designers or artists oriented. Then I’ve found IwGame and I must say that I’ve rarely seen a high level library so well written, well thinked and well documented (I also love it because it’s very similar to my style of programming…).
    Just my two cents and thank you for your amazing work.

Leave a Reply