IwGame Engine v0.29 Released – XOML is evolving

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.

The Universe conspired against me this week, first of all landing me with a nice flu, followed directly by some horrible sickness bug that featured projectile vomiting of the likes only seen in movies such as the Exorcist! Thankfully the Universe decided to give me a break this week so an IwGame Engine update got finished.

Most of the changes this week are XOML related as this is the general direction we want to take the game engine. A good mix of XOML mark-up and solid coding should make games and media apps very quick and easy to develop.

Oh and we got a new logo for the IwGame Engine woohoo! Feel free to use the logo in any of your IwGame powered products, or if you want to link to us.

Ok, onto the list of iwGame Engine changes for v0.29:

  • New style system added to XOML. Actors and scenes can now use a style to reduce repetition
  • Actors and scenes now handle events such as OnSuspend, OnTapped, OnBeginTouch etc.. When an event fires it executes a collection of actions
  • Actions added to XOML to allow definition of collections of actions that can be executed. Many default actions are suppported such as ChangeScene, KillScene, PlayTimeline, PlaySound etc.. Custom actions can also be added toextend the system
  • CIwGame now handles touch begin touch, end touch and tapped events
  • CIwGame now has new Postdraw() method for adding in custom post draw rendering
  • Actors can now be made tappable and now handle OnTapped(), OnBeginTouch() and OnEndTouchEvents()
  • Actors have new HitTest() method that can be used to check if a point is inside the actors visual
  • XOML now supports creation of cameras
  • XOML now supports creation of variables and update of variables using actions, supports string, bool, int, float, vec2, vec3 and vec4
  • XOML files can now load other XOML files with new LoadXOML tag as well as LoadXOML action
  • Scenes now support a type field
  • CIwGameBitmapSprite now supports image transforms (flips. mirrors etc) which can be also applied to actors visuals using FlipX and FlipY attributes
  • You now change the current time of a CIwGameAnimInstance and CIwGameAnimTimeline
  • Bug Fix – Actor visibile state now works properly
  • Bug Fix – CIwGameShape::setShape() now works
  • Bug Fix – Transform is now reset after CIwGameAdsView finishes rendering
  • Bug Fix – JPEG file detection fixed, was not detecting certain types of JPEG files
  • Bug Fix – CIwGameString::FindNext() crash fixed

Quite a few changes and bug fixes. Note that someo f the bug fixes directly affected IwGameAds so an update to that API will be released shortly.

Lets take a look at the changes in more detail.

XOML Variables

XOML got variables, but why? Well, there are a number of reasons:

  • We want to be able to define values that can be read by the main code
  • We want to change these values via actions
  • When we implement the UI system we are looking to add data binding capabilities that will rely on values

You can declare a variable in XOML like this:

    <Variable Name="PlayerName" Type="string" Value="Player One" />
    <Variable Name="PlayerScore" Type="int" Value="0" />
    <Variable Name="PlayColour" Type="vec4" Value="255, 128, 64, 8" />

You can later modify the value of that variable using a SetVar action, more on this later.

Each scene contains its own variables collection and the global resource system also contains a global variables collection.

XOML Styles

XOML now supports the styling of actors and scenes using the new Style tag. XOML styles enable you to create a set of properties and values that are common across a range of objects then apply tat style the to them all. Hers a quick

example:

<Style Name="BasicActorStyle">
    <Set Property="Size" Value="60, 60" />
    <Set Property="Angle" Value="0" />
    <Set Property="SrcRect" Value="0, 0, 36, 40" />
    <Set Property="Image" Value="Sprites" />
    <Set Property="Timeline" Value="Player1Intro1" />
    <Set Property="Shape" Value="PlayerShape" />
    <Set Property="Box2dMaterial" Value="BounceyBall" />
    <Set Property="CollisionFlags" Value="1, 1, 1" />
</Style>

<TestActor Name=”Player2″ Style=”BasicActorStyle” Position=”0, -150″ />

The TestActor Player2 will be assigned all of the values in the properties defined in the style saving you a whole bunch of typing as well as making your mark-up much more readable and easier to maintain.

XOML Events And Actions

Actors and scenes now support various events that can fire off user defined actions. The following events are currently defined:

Scenes:

  • OnSuspend – Called when a scene is suspended
  • OnResume – Called when a scene is resumed

Actors:

  • OnTapped – Called when the user taps an actor
  • OnBeginTouch – Called when the user begins to touch an actor
  • OnEndTouch – Called when the user stops touching an actor

More will be added as we think of them or when requested. You can also add your own custom events youself. Check out the CIwGameActor class for a reference on how to do this.

Events wouldn’t really be much use unless we could carry out some kind of action when the event occurred. Actions are defined in XOML using the Actions tag, heres an example:

<Scene Name="GameScene3" Style="GenericSceneStyle" OnSuspend="SuspendActions">
    <Actions Name="SuspendActions">
        <Action Method="SetTimeline" Param1="SceneTransition1" />
        <Action Method="PlaySound" Param1="explosion" />
    </Actions>
</Scene>

You actually create a group of actions that are all executed when the action is called by an event.

The following actions are currently supported:

  • ChangeScene – Changes the currently focused scene to the specified scene
  • SuspendScene – Suspends the specified sceme
  • ResumeScene– Resumes the specified sceme
  • HideScene– Hides the specified sceme
  • ShowScene– Shows the specified sceme
  • ActivateScene – Activates the specified sceme
  • DeactivateScene – Deactivates the specified sceme
  • KillScene – Destroys and removes the specified sceme from the game, all contained resources amd actors will be also be destroyed
  • HideActor – Hides the specified actor
  • ShowActor – Shows the specified actor
  • ActivateActor – Activates the specified actor
  • DeactivateActor – Deactivates the specified actor
  • KillActor – Kills and removes the specified actor
  • PlayTimeline – Plays the specified timeline. If no timeline is supplied then the current actor / scenes timeline will be restarted (depends on where the action was defined)
  • StopTimeline – Stops the specified timeline. If no timeline is supplied then the current timeline will be stopped. (depends on where the action was defined)
  • SetTimeline – Changes to the specified timeline. If no timeline is supplied then the current timeline will changed and restarted. (depends on where the action was defined)
  • PlaySound – Starts playing a sound effect
  • PlayMusic – Starts the playing specified music file
  • StopMusic – Stops the music player playing
  • LoadXOML – Loads a XOML file into scene or globally. If a scene is provided then the XOML will be loaded into that scene
  • SetVar – Sets the value of a variable

Again, more will be added as we think of them or when requested. You can also add your own custom actions youself. Check out the CIwGameXomlAction_Actors class for a reference on how to do this.

Coupled together the events and actions system provide a very powerful way of creating fully interactive content without having to write a single line of code.

Loading Other XOML Files

It is now possible to load other XOML files from a XOML file using the new LoadXOML tag. Heres an example:

<LoadXOML File="Common.xml" />
<LoadXOML File="Sceme2.xml" />
<LoadXOML File="Scene3.xml" />

You can also (as shown in the actions section) load a XOML file from an action.

Using this system you can create fully interactive navigation based content. Think adventure games, books, magazines and informational apps etc..

Scene Cameras

Cameras can now be defined in XOML and attached to scenes. You can also switch a scenes camera using the animation system.

Image Transforms for Sprites and Actors

Sprites and actors can now use an image transform allowing you to flip the source image used to render the object. The ne FlipX and FlipY attributes are now available in XOML.

Well thats it for this update. IwGame now has some very cool features that should hopefully make game / app development much easier and quicker for everyone.

We are going to assess the possibility of wrapping up Marmalades cool UI system with XOML very soon, will keep you all posted on how that goes. I am also looking at producing a new article on in-app purchasing with the Marmalade SDK, which will form the basis of in-app purchasing for the IwGame engine.

84 thoughts on “IwGame Engine v0.29 Released – XOML is evolving

  1. Mat,

    Thanks a lot, what a beauty!!!!!

    this is the first time I download your Engine and start stripping my code from all the non sens that I implemented. XOML will reign!!!!

    I just noticed the Color.a changes in the engine’s code, I assume they are to be removed?

    void CIwGameActor::OnBeginTouch(int x, int y)
    {
    ProcessEventActions(CIwGameXomlNames::OnBeginTouch_Hash);
    // Colour.a = 0x80;
    }

    void CIwGameActor::OnEndTouch(int x, int y)
    {
    ProcessEventActions(CIwGameXomlNames::OnEndTouch_Hash);
    // Colour.a = 0xff;
    }

    I can’t have enough of this IwGame!!!!!
    have a great evening Mat

    Criss

  2. Mat,

    You did a really great job on this update!! It is all that I had hoped for and more. Adding variables was icing on the cake. Thanks! I’m still unpacking all the new stuff.

    My projected ported over okay, except that whenever I click on the simulator, or hold the mouse button down, the simulator dims like the backlighting goes out. Any ideas?

    Again, great job! Glad you’re well, too.

    Keith

  3. Hello, Criss,

    Thanks for the help! I haven’t gotten around to using most of the new code as I, too, am redoing and rethinking my klutzy work arounds.

    And you’re right: XOML rocks!

    I’ve got a tweak or two I’ve made I’d like to run by you, but this probably isn’t the place for that. I’ll see if Mat will forward my email.

    Keith

  4. Hi Mat,

    I am not noticed about updates on your site to my rss reader. Other stuff works so I guess it is problem on your side.

    I am going to port my small flash game with your engine and will let you know how it goes.

    At least really small complete example how to set all those stuff together would be great Even any avoider game, with Start screen, Game screen, and Game over screen would be enough.

  5. Hi Roman,

    Funny you should mention that, I’m currently working on putting together a small app with those types of things in there. Will let you know when its ready.

    I’m a bit of a WordPress noob so its probably something I’ve managed to break at my end.

    Mat

  6. Ok, so I am waiting for it.

    I have a simple game which was accepted to Apps Program and would love do it with IwGame. It would be great to see your example app soon, because I have no much time:)

    It looks that with RSS you fixed it, because I got 3 messages about new post on your blog, so everything works now.

  7. That’s great news about being accepted into the apps program. Is it already available on another platform?

    Had to spend most of today upgrading IwGame to support linking of actors to allow compound transforms and transform offsets, but the demo will be back on track tomorrow.

  8. Sorry, I missed your question.

    It is not released yet flash game. Really simple concept, earlier version you can play here:
    http://bit.ly/zPT0Bp
    If you are curious what will be made in your engine:) There is no preloader so wait for a second to see it.

    I have to change title because of Sony Ericsson copyrights to QuadraPop name I wasn’t aware.

    I see that some demo is attached to IwGame. Sorry for that, I have followed your blog since it started, but haven’t tested it very intensively. That example should help me to port that game really quickly. I have to idea how to do flip page effect in your engine, and how to do font rendering for points for example, but I hope to solve those problems when I dive into it.

    I had a strange bug with #include “Box2D/Box2D.h” in test bed demo.
    I got error that this file doesn’t exist, but I delete that line, write down exactly the same and that started work. I have no idea why. Maybe some kind of strange Xcode behavior?

  9. Hi Mat,

    I finished porting my code to the new version, apparently this has introduced a problem.

    OK, here’s my scenario: I have a scene with multiple pins (Actors) that the user clicks on so that he/she goes to a level to play. Once clicked, I call the following code from Actor’s :: onTapped(x,y) :

    getScene()->setActive(false);
    getScene()->setVisible(false);
    getScene()->setAllowSuspend(true);

    // Locate the MAP Scene and activate it
    CIwGameScene* currentScene = GAME->findScene(“Level1”);
    if (currentScene != NULL)
    {
    GAME->initLevel1();
    currentScene->setActive(true);
    currentScene->setVisible(true);
    currentScene->setAllowSuspend(false);
    GAME->changeScene(currentScene);
    }

  10. ****** sorry I clicked accidentaly on Post 😉 ******

    the method ChangeScene() deactivate the current Scene and enables another one…and if I understood it correctly, changeScene() will allow the calls to OnTapped(int x, int y), OnBeginTouch() and OnEndTouch() to happen.
    Inside the scene “Level1”, I have few ActorButtons and some spawned monsters(they’re actors too)… if I click on the buttons, they work perfectly, but If I tap on the spawned monsters the application quits on me.
    The difference between the buttons and the monsters is that the buttons are declared in the XOML file and the mosnters are created dynamically.

    Any ideas on how to get around this problem or if I am doing something’s wrong???

    thanks
    Criss

  11. Mat,

    Nevermind that… after some careful debugging, I noticed that when the user clicks or taps on any of the dynamically spawned monsters I was not returning false on its update, therefore, the tap crawled toward the background and crashed the app.

    Sorry about this.
    Criss

  12. Thanks Mat,

    I just notice that when I touch the screen of my device with two fingers, I stop getting reactions from the game. I tried it on the TestBed as well and its occuring.

    Do you have a quick remedy for this?

    Thanks
    CRISS

  13. Currently the touch code in scene is designed to work with single touch, but it messes up under multi-touch conditions. Right now we haven’t figured out a way get the general single touch style gestures working with multi-touch inputs. We will add a small change in there on the next update that will allow the system to work under multi-touch

  14. Bumper for that 🙁 but I’ll wait for the next release 😉

    On a side subject, is there a way to reset a Scene?

    The reaon being is that if the user is playing a Level and he decides to take another shot at it, he hits a replay button and the scene is reset and the monsters starts generating again…etc… its like reloading the scene from the XOML file.

    I only thought of one solution for this, it is to delete all the Enemy actors that were spawn during that session but I am facing some crashes. here’s the code that I added to CIwGameScene in order remove all the actors with a certain type:

    void CIwGameScene::clearAllActorsOfType(int type)
    {
    // Remove and delete all actors from the scsne (only delete if actors are not managed)
    for (_Iterator it = Actors.begin(); it != Actors.end(); ++it)
    {
    if ( type == (*it)->getType() )
    {
    removeActor(*it);
    }
    }
    }

    What is your recommendation on this?

    Thanks
    Criss

  15. Yep, you are removing the actors inside the iteration loop, so the list of actors changes. Note that CIwGameScene already has a method to remove all of the actors:

    void CIwGameScene::clearActors()

    This will delete all actors and clear the actors list.

    You have presented a good idea about resetting all the actors in a scene, I like it. I will see if I can add something in there to reset all of the scenes actors. It would entail keeping the XOML around in memory however. Will take a look to see if it possible.

    Got some cool new features coming in v0.30 that may help:

    You can now define a collection of actors using an actor template. The actors are not actually added into the scene until you instantiate the template either in code or by using XOML like this:

    <FromTemplate Prefix=”T1_” Template=”ActorTemp1″ Position=”0, -50″ />

    So you define a template that contains 10 actors then instantiate those 10 actors using FromTemplate tag.

    The reason for this new addition is to allow you to build more complex actors from multiple actors then instantiate lots of copies of them. This is associated with the next change which is linked actors.

    Linked actors allow you to tell one actor to follow the transform of another actor (kind of like actors contained within other actors). Here’s an example:

    <TestActor Name=”PlayerA” Style=”BasicActorStyle2″ AngularVelocity=”-0.5″ >
    <TestActor Name=”PlayerB” Style=”BasicActorStyle2″ AngularVelocity=”-0.5″ Origin=”50,0″ Scale=”0.5″ >
    <TestActor Name=”PlayerC” Style=”BasicActorStyle2″ AngularVelocity=”5″ Origin=”50,50″ Scale=”0.5″ />
    </TestActor>
    </TestActor>

    Here we define PlayerC as a child of PlayerB, which is in turn a child of PlayerA. So when PlayerA is transformed, PlayerB will also be transformed by PlayerA’s transform then by its own transform.

    Using this type of actor definition allows you to define very complex actors entirely in XOML.

    We’ve also added none uniform scaling into the sprite / actor system as well as the concept of a geometry origin which modified the central point of rotation / scaling of them.

    Delta animations have also been added, which allows you to update the properties of objects using a delta value instead of absolute value, which allows you to do stuff such as move left 5 pixels, rotate clockwise 5 degrees etc..

  16. Mat,

    I am not removing all the actors, I am removing all the actors that have a certain Style, say only monsters…
    But when I am calling this method above, I am having some crashes.

    What’s the right way of calling such methods without crashes? Does the scene need to be non-active, non-visible and/or suspended?

    Thanks for your feedback
    Criss

  17. Take a look at CIwGameScene::Update(). What I do is build a list of all the actors that I want to remove like this:

    // Process the actors
    CIwList removals;
    for (_Iterator it = begin(); it != end(); ++it)
    {
    if (!(*it)->Update(dt))
    removals.push_back(*it);
    }

    Then go through that list removing all of the actors using:

    // Remove any deleted actors
    for (_Iterator it = removals.begin(); it != removals.end(); ++it)
    removeActor(*it);

    You could do this some other way by modifying the actual iterators, but the above suffices for the purposes of the scene.

    You don’t need to hide / deactivate the scene etc..

  18. Thanks for this, I will try it.

    Now how can I best kill a monster using the latest OnTapped() method?

    Now my monsters are flying around the screen and when tapped, they trigger a graphical explosion which is another animation based on scaling an Actor that has an image of a blow. It takes 0.6s to blow, now if the user keeps clicking on the same area of the screenduring that time, I am getting a crash, but if I wait until the blow is done, nothing happens and the game keeps running.

    I did set the setTappable to false on the explosion actor.

    The way how I am killing my monster is the following:

    in OnTapped, I added this:
    void myActor::OnTapped()
    {
    wasShot = true;
    }

    and in my Update() I am doing the following:

    bool myActor::Update()
    {
    if (wasShot)
    return false;
    }

  19. ****** again I clicked accidentally *******
    ***** I think there is a shortcut that I pressed by accident *******

    I hope I was clear in explaining my problem.
    Again, I can’t thank you enough.

    Cheers
    Criss

  20. The crash is occuring in “CIwGame::ProcessEvents()” in the last if condition.

    // Handle end touch event (only actor that received begin touch event needs to handle this)
    if (PrevTouch && !touch)
    {
    if (TouchFocus != NULL)
    TouchFocus->OnEndTouch(pos.x, pos.y);
    TouchFocus = NULL;
    }

    The TouchFocus is different than NULL, but the scene inside it is set to 0xddddddddd

    Do you think we need to add:
    CIwGameActor* tapped_actor = CurrentScene->FindTappedActor(pos.x, pos.y);

    inside this condition and use tapped_actor instead?

    Thanks for looking into this.
    Criss

  21. No, nothing is valid inside TouchFocus, all the numbers seems wrong. however, I tried adding
    TouchFocus = NULL at the beginning of ProcessEvents() right after testing for the validity of currentScene and it seems giving me better results. no more crashes for now, but I am not sure what’s the impact of this throughout the whole application.

    Criss

  22. ok, I just find out the impact of this. Most of my other buttons that were pressed are stuck in the buttonDown position and they’re not togglling back to their ButtonUp state 😉
    please note that I used XOML’s onBeginTouch and onEndTouch to implement these buttons. Their Actions are straighforward:

    any thoughts?
    Criss

  23. Yes, the call is there.
    Actually my project is based on the TestBed that you provided. so not a lot of changes there except some of my own Initialisations

    The crash is happening when I perfom some quick clicks on the screen if I am on the PC, or with plenty of tapping on the device.

    to answer your questions above:”Are you deleting an actor but still referencing it from elsewhere?”

    Yes I am deleting that actor that was tapped on and that actor was spawned using a monsterGenerator using the same approach that you used in
    ActorPlayer::Create() in your testBed. Now, this monster spawns an explosion when he’s being tapped on…

  24. Ok, I think that I’ve sussed it out. When you delete the actor the game still has that actor as its touch focus even though the data is no longer valid.

    I am going to add some code into IwGame / IwGameScene to check if an actor that is about to be removed is the touch focus and if it is then it will release the touch focus before it deletes the actor.

    I’m currently busy trying to get a bunch of small demos together to help developers learn to use IwGame easier, will do the update when I’ve got the first done. Hopefully over the weekend.

  25. Thanks a lot Mat,
    I will be looking forward for this change that you will provide as well as the demos/tutorials regarding the engine.
    I know I have acquired lots of experience using the engine just by trying a bunch of stuff or by hitting walls and trying to find a way around them 😉

    Its turning out to become a great product.

    Cheers to that.
    Criss

  26. Hey Dr. Mop,

    I noticed that there was a bug in your current Engine that people were talking about, where if u tap an actor it goes transparent.

    Recently, for my user inputs for taps, I have been creating an invisible actor to collide with the actors collision circles. I noticed that in your bug, if you click anywhere on an actors visual the actor responds by turning transparent.

    The way my touch interface works, you have to tap the center of an image, so recently my rectangles with a long width and small height can only be activated by touching the center of the image. The collision circle also goes slightly past the visual, above and below.

    What function do you use to make it so the user can touch any part of the actors visual?

    Thanks

    Thomas

  27. Hi Mat,

    I have a suggestion regarding :
    bool CIwGameAudio::PlayMusic(const char* name)

    Can you override it so that it accepts a 2nd parameter that will handle the number ot times the music is repeated? something like:

    bool CIwGameAudio::PlayMusic(const char* name, int repeatCount)

    and replace the 0 in s3eAudioPlay(name, 0) with repeatCount?

    Everytime you send a new version of the engine I am doing this. I am sure there are lots of use cases where developers wants to play the music track only once….

    Just a suggestion…
    Have a great weekend

    Criss

  28. @Thomas: The following method iws used to determine if the the point where the user taps the screen is within an actors visual:
    bool CIwGameSprite::HitTest(int x, int y)

    The transparency bug will be gone next week when we release 0.3 of IwGame.

    @Criss: Consider it done

  29. Thanks for the reply. I’ve tried messing around with HitTest, but have been unable to get it to work. I can’t seem to figure out what x and y values need to be passed. Do you think you can explain it to me if my actor’s image is 64 by 32. Thanks

  30. Thanks Mat,

    Can’t wait for ver. 0.30

    Will it include some simple text rendering as well, the one that you mentioned once?
    I still haven’t got that to work properly 🙁 even if I used PostDraw()…maybe my best bet is to derive CIwGameSprite.

    Cheers and have a great Sunday
    Criss

  31. Hi,

    Just tries the new PostDraw() method.
    When drawing in this method using Iw2DDrawString the 0,0 coordinate is always the 0,0 of the last actor drawn from the XOML. Is this meant to be ?
    I am calling my own PostDraw method on some of my actors, how can I use the base coordinate from the actor I am working with ?
    Thanks.

  32. @Martin:
    The Iw2D transform will be the last transform that was used to render a sprite. You will need to set up your own transforms at this point.

    To get the actors visual base transform call actor->getVisual()->getTransform();

    Note that as of v0.30, we no longer use the Iw2D rendering pipeline and it has been replaced with IwGx and our own batch renderer.

    @Criss:
    v0.30 should appear some time next week (hard top say as I want the game demo to be ready with it). Will take a look, see if we can add some kind of text rendering test in there, but cant promise that it will appear.

  33. Good Morning Mat,

    Thanks a lot for all the feedback that you are providing and sorry if I am bugging you a lot with my questions. But the more I use this awesome engine the more I feel like I wanna do more with it. so here’s another question:

    Let’s say I have two actors (A and B) inside one Scene, both actors have their own derived classes.
    I want to click on actorA to change the state of Actor B. To do this, I modify a global variable from the onTapped() method of Actor A :

    void ActorA::OnTapped(int x, int y)
    {
    CIwGameActor::OnTapped(x, y);
    GAME->thisVariable = 1;
    }

    Now, inside the Update() of ActorB, I am doing the following but its not working:

    bool ActorB::Update(float dt)
    {
    if (GAME->thisVariable == 1)
    {
    CIwGameAnimTimeline* timeline = (CIwGameAnimTimeline*)getScene()->getResourceManager()->findResource(“SpeakerONTimeLine”, CIwGameXomlNames::Timeline_Hash);
    setTimeline(timeline);
    } else {
    CIwGameAnimTimeline* timeline = (CIwGameAnimTimeline*)getScene()->getResourceManager()->findResource(“SpeakerOFFTimeLine”, CIwGameXomlNames::Timeline_Hash);
    setTimeline(timeline);
    }

    return CIwGameActorImage::Update(dt);
    }

    SpeakerONTimeLine and SpeakerOFFTimeLines are two timelines that have only one Animation each. The Animations represent two different sprites on the SpriteSheet that are related to SpeakerOn and SpeakerOFF.

    For some reason, the TimeLine is not being set therefore the speaker icon is not changing.
    Am I doing this right?
    Is this the correct place to change the TimeLine for an actor?
    or
    Is it enough just to set the timeline like this, or do I need to do something else?

    I know you’re busy with 0.30 (which I am looking forward to:-) ) but can you just share your thought regarding this?

    Thanks
    Criss

  34. Do you start the timeline playing after you have assigned it to the actor?

    Can you check to ensure that OnTapped() is actually getting called? Also check an make sure that the timeline is actually being found and not returning NULL.

  35. So I presume that I am calling setTimeline from the correct place.

    -I called : timeline->play() inside update() nothing happened.
    -my timeline is not NULL, it is a valid object.
    -I have set inside my timeline definition in XOML AutoPlay=”true”
    -the onTapped in ActorA is accessed.

    What should the Duration in the Animation be for a one frame Sprite? what about the Time of its frame. Here’s mine:

    #Animation Name=”SpeakerOnAnim” Type=”rect” Duration=”0″ #
    #Frame Value=”2, 2, 411, 141″ Time=”0.0″ #
    #/Animation#

    and here’s my timeline definition:

    #Timeline Name=”SpeakerONTimeLine” AutoPlay=”true”#
    #Animation Anim=”SpeakerOnAnim” Target=”SrcRect” Repeat=”0″ StartAtTime=”0″#
    #Timeline#

    so weird…..

    🙁

    Regards,
    Criss

  36. Hi Mat,

    Finally, I decided to use the collision system that you implemented in the engine while disabling Box2D and I think I found a small bug that prevented the collisions to happen between actors but I could be wrong .
    I found out that setCollisionSize() is not setting the variable “CollisionSize”. I added a call to setCollisionRect() at the end of setCollisionSize() which in turn sets the CollisionSize variable correctly and I ended up with this:

    void CIwGameActor::setCollisionSize(int size)
    {
    CollisionRect.x = -size >> 1;
    CollisionRect.y = -size >> 1;
    CollisionRect.w = size;
    CollisionRect.h = size;
    setCollisionRect(CollisionRect);
    }

    Is this a good approach to set the CollisionSize variable or was there another way you intended us to do it?

    Thanks
    Criss

  37. Sorry, incredibly busy at the moment so no had chance to look into this. An animation of 0 duration should still work, not actually tested that though.

    I’ve applied a fix for setCollisionSize() at this end, will appear in v0.3

  38. Mat,

    With regards to Criss’s #43: I’m running a simple code loop to examine an animation that was setup in XOML, with the animation repeat set to 1. When I use play(), it will only run once, even if a different animation is run after it. However, if I use restart(), it works fine. Does play() need to be somehow reset? It is finding and accessing the animation from the list, but I think it’s reading the repeat=1 as being completed.

    Thanks,
    keith

  39. Play does not restart the animation as its meant to be used to play an animation from pause as well as to initially start an animation playing. You need to restart() an animation if you want to start it playing again.

  40. Hey Dr. Mop,

    I can’t seem to get the HitTest funtion to work.

    CIwFVec2 pos = Level1_Scene->ScreenToVirtual(IW_GAME_INPUT->getTouch(0)->x, IW_GAME_INPUT->getTouch(0)->y);

    if (Level1_Scene->findActor(“MenuButton”)->getVisual()->HitTest(pos.x, pos.y) == true)
    {
    // dothings
    }

    Would this be the right way to set it up? It doesn’t seem to work when I debug. Thanks.

    Thomas

  41. Sweet it worked! However I have now encountered a new problem. I have a total of 4 scenes so far that I am working on and for some reason only 1 scene out of the 4 works with your bug. This also means that I can only use the HitTest method above in this scene. Is there a property I need to enable or disable of an actor of scene that will allow for Hit Testing. I will tinker around with the code tonight and see if I can get the other scenes to reciprocate the bug and the Hit Test.

  42. I think I’ve isolated the problem on my end. It seems that if there is a camera active with the scene, then the HitTest function does not seem to work. Is this a bug? Or am I doing something wrong with my code.

    Also I would like to address the changeScene() method. Whenever I need to change my scene, I not only have to use this function but I need to use the scene->setActive() and scene->setVisible() methods, or else the scene will not become visible nor active. changeScene() only changes a few things for me, such as activating the camera, and I am wondering if it was intentionally coded this way, or if something is going wrong on my end. I think the changeScene() method should set visibility and the active state of the scene to true. At least on my end it does not do this.

    Thomas

  43. There is a bug in the sprite renderer transform that I fixed the other day, this will appear in 0.3.

    ChangeScene() is meant just for changing the current scene and not changing internal states of scenes. The best way to make the scene visible / active is to override NotifyResuming() and set the scene visible and active in there.

  44. There is a lot of broken stuff right now… waiting for 0.3

    Since drmop is actually doing some game demos now, I know that lots of stuff will be fixed, it’s only until you eat your own dog food that you know you have to improve the taste of it.

  45. Yes, its also lead to many more new and cool features 🙂 For example, we just added depth to sprites so they can now be placed in 3D, allowing easy creation of parallaxing effects.

    Just this minute fixed a crash bug which only appears on devices. We were deleting the resource manager before the scenes attached camera. Fixed all sorts of other minor bits and bobs too.

    So far got intro screen, main menu, level select and main game background working in 100% XOML with no extra coding. Aiming for finished game demo by this weekend along with engine and documentation updates.

  46. Definitely… that is exactly how I am used to do it. First I come up with the design/API then I start using it, well most of the time there are a lot of adjustments or missing features/options that have require rethinking.

    For v0.3 this project has been frighting fast, it’s a blessing but a curse in ways, since code isn’t stable enough *yet* to fully commit to the project.(i.e. use it as our platform).

    Personally I dislike to write XML, so I will wait for the editor and do things programmatically for the time being 😉

  47. The engine should be very stable once this game is complete. Although to be honest, there has been very few serious bugs that couldn’t have been fixed by anyone. Our frog game should provide a good example of what others can do quite quickly (this game demo is a one man job, including all the “programmer art work” lol :D. The game is basically designed around XOML, with XOML providing the layouts and tying up of events / actions etc… The main game logic is implemented in the scenes / actors. Its unfortunately taking a little longer than expected as the game is turning out to be much better than e had imagined (we may even submit it to the app stores!)

  48. Hi Dr.Mop!,

    First of all, let me tell you that you have done an excelent work with IwGame! I’ve been following your marmalade tutorials and the IwGame development since the beginging, and it’s been an excelent help.

    I’ve a doubt, with box2d collisions. I’m fairly new to mobile game development, so probably I’m doing something wrong with the math or the configuration related to the collisions.

    I’ve a simple application, where a little ball hits a wall. I define the scene, actors and materials as follow…
    (I’m removing unnecesary parts in the message):

    <Scene …

    I run the application in the simulator (and on an iphone, with the same results). The ball goes into the wall, and instead of hitting the wall and then turning back, the ball goes inside the wall up to half the wall material.

    I tried several thing, until I changed the height of the wall to 20 (the exact double):

    After that, the ball hits the wall and then bounces back as expected (without going into the material of the wall).

    I don’t think this is the way to define the shapes and the actors, so I must be doing something wrong? Any clue?
    I’ve searched the blog and the documentation, but I’ve didn’t found anything.

    Thanks in advance for any help!

    Pablo

  49. Hi Dr.Mop!,

    First of all, let me tell you that you have done an excelent work with IwGame! I’ve been following your marmalade tutorials and the IwGame development since the beginging, and it’s been an excelent help.

    I’ve a doubt, with box2d collisions. I’m fairly new to mobile game development, so probably I’m doing something wrong with the math or the configuration related to the collisions.

    I’ve a simple application, where a little ball hits a wall. I define the scene, actors and materials as follow…
    (I’m removing unnecesary parts in the message):

    <Scene …

    <Box2DMaterial Name=”WallMaterial” Type=”static” Density=”1″ Friction=”0″ Restitution=”1″ />
    <Box2DMaterial Name=”BallMaterial” Type=”dynamic” Density=”1″ Friction=”0″ Restitution=”1″ />

    <Shape Name=”Ball” Type=”circle” width=”16″ height=”16″ />
    <Shape Name=”HWall” Type=”box” width=”260″ height=”10″ />

    <XomlActor Name=”TopWallActor”
    Position=”0,-200″
    Size=”260,10″
    Angle=”0″
    SrcRect=”0, 0, 10, 10″
    Image=”Block”
    Shape=”HWall”
    Box2dMaterial=”WallMaterial”
    CollisionFlags=”2, 4, -1″ />
    <XomlActor Name=”BallActor”
    Position=”-50,-50″
    Size=”16,16″
    Angle=”0″
    SrcRect=”0, 0, 16, 16″
    Image=”Ball”
    Shape=”Ball”
    Box2dMaterial=”BallMaterial”
    CollisionFlags=”4, 2, 1″/>
    </Scene>

    I run the application in the simulator (and on an iphone, with the same results). The ball goes into the wall, and instead of hitting the wall and then turning back, the ball goes inside the wall up to half the wall material.

    I tried several thing, until I changed the height of the wall to 20 (the exact double):

    <Shape Name=”HWall” Type=”box” width=”260″ height=”20″ />

    After that, the ball hits the wall and then bounces back as expected (without going into the material of the wall).

    I don’t think this is the way to define the shapes and the actors, so I must be doing something wrong? Any clue?
    I’ve searched the blog and the documentation, but I’ve didn’t found anything.

    Thanks in advance for any help!

    Pablo

  50. @Roman,

    in your .ICF file and inside the S3E section, add the following:

    [S3E]
    DispFixRot=1 #2: for landscape, 1: Portrait, 0: Native device orientation

    Cheers,
    Criss

  51. @Pablo: Your ball shape is defined as a circle but you provide width and height instead of radius.

    @Roman: Its unfortunately going to take longer, I’ve lost a lot of work time due to the flu.

  52. @Criss: We went ahead and added full support for text based actors in code and in XOML. The sprite system got a new CIwGameTextSprite class, which enabled you to render text as a sprite. We also added a new actor type CIwGameActorText so you can create text based actors. In XOML you can create a text base actor like this:

    <ActorText Name=”Text1″ Position=”0, -260″ Rect=”-400, -50, 800, 100″ Angle=”0″ Font=”trebuchet_12″ AngularVelocity=”0″ Text=”Hello World!” Colour=”255, 255, 255, 255″ Scale=”1.5″ />

    Text can be scaled, rotated, layered, linked, depth added etc, just like any other actor. You can even put them under control of Box2D physics 🙂

  53. Yes, ActorText will be available next week in 0.3. We’ve decided to release 0.3 even if the game isn’t fully complete. I will keep it updated however. After 0.3 we will set about creating more simple examples of IwGame usage as well as on-line tutorials

  54. Hi,

    I’ve a little question. Inside que class “IIwGameXomlResource”, we have the protected properties Name and ClassType, but only if “_DEBUG” is defined.

    I’m doing some collition tests with Box2D. Inside the code that checks with what other actor I’m colliding I retrieve the other CIwGameBox2dCollidable.
    Something like this inside the game Update code:

    XomlActor* actor = (XomlActor*)scene->findActor(“BallActor1”);
    CIwGameBox2dCollidable::_CollisionIterator it = (actor->getBox2dBody())->started_begin();
    while (it != NULL) {
    CIwGameBox2dBody* body = (CIwGameBox2dBody*)it.st->el;

    // Find out to which actor the body matches….

    it++;
    }

    From the body variable, I can only get the shape, and inside the shape, I can get the name, but only if _DEBUG is defined. Also I do not have a getter for this property (I have to add it to IIwGameXomlResource.

    Maybe the collition test is wrong (I’m just testing it), but I’m curious why the name is not present in the resource. Is it a performance reason?

    Thanks!
    Pablo

  55. Good Morning Mat,

    Thanks a lot for implementing ActorText in this coming version (which I am soooooo excited about…) This is very a useful feature and I am sure that it will be used heavily by many not only to display information and data pertinent to the game, but also to do some onScreen debuging. I think every new game developer will find this as a great feature to have.
    About this new release, I really can’t wait to lay my hands on it. Lots of new features you mentioned earlier and I can’t wait to start tinkering with:
    -The Actor Templates.
    -The Linked Actor.
    -Uniform Scaling.
    -Delta animations (I think this is a cool feature to have and it saves lots of coding)

    I am so much greatful that I started getting to fiddle around with IwGame before it was even an Engine, it was back in the days when it was still a bunch of tutorials 😉 😉

    Good Job Mat and please if you think that there are ways that we can help, please let us know, I am sure that there are lots of people outthere who appreciate what you’re doing and will be ready to go the extra mile to help. Count me in.

    This is been said, I would like to share (if I may) with all the community of IwGame this website that I found by chance:

    http://www.bfxr.net/

    It allows you to create sound effects of all sorts on the fly and download them right into your game. Gosh, it saved me tons of hours looking for free sound effects for my humble games.

    Cheers,
    Criss

  56. @Pablo: We don’t carry the strings around in release mode as we do not need them. We use the hashed string values instead, e.g.:

    if (object->getClassTypeHash() == CIwGameString::CalculateHash(“MyType”))
    {
    }

    Comparing hash values are much faster than comparing actual string data.

    The string versions are there during debugging to enable us to make reading the classes name and type.

    @Criss: No problem. The best thing we can hope for is for developers to create great games using IwGame and spread the word, oh and report any bugs that they find. Thanks for the sound generator link

  57. Mat, Ive start to play with your TestBed app and I think I don’t understand some basic concepts with loading resources manually.

    Let me show a very simple example based on your app. That code putted in Game::Init() works ok, and image is loaded:
    IW_GAME_XOML->Process(this, “Common.xml”);
    CIwGameImage* image = (CIwGameImage*)IW_GAME_GLOBAL_RESOURCES->getResourceManager()->findResource(“sprites”, CIwGameXomlNames::Image_Hash);

    But when I try do it manually image is always null:
    CIwGameResourceGroup* group = new CIwGameResourceGroup();
    group->setName(“Level1”);
    group->setGroupFilename(“Level1.group”);

    IW_GAME_GLOBAL_RESOURCES->getResourceManager()->addResource(group);
    group->Load();

    CIwGameImage* image = (CIwGameImage*)IW_GAME_GLOBAL_RESOURCES->getResourceManager()->findResource(“sprites”, CIwGameXomlNames::Image_Hash);

    I guess I miss something really obvious?

  58. Hi!,

    Just a little question. As far as I’ve tested (Using the Testbed as a reference), all the coordinates in a scene are relative to the 0,0 coordinate (in the middle of the virtual canvas). Is it possible to move the 0,0 to the upper left corner of the display
    It makes no big difference to me, but in some concrete example I’m working, would make the math a little simpler.

    I’ve tried moving the camera to that position, but that had no effect.

    Thanks!
    Pablo

  59. Hmmm, it looks that you are right for some part. I played with it once again and looks like moving the camera has impact on actors, but not on sprites (in my case it was CIwGameBitmapSprite. What you have on your scene? MAybe it is a bug?

  60. @Roman

    I’m building a simple air hockey game. I have the following actors: two walls, two pushers, a background and a disk. Nothing special. As I’m used to work with the coordinates root at the left top corner of the device, I was trying to emulate that with IwGame. So far I’ve changed everything to use the coordinates root in the middle of the screen

    thanks!

  61. Another question (sorry :))

    Is it possible to set a background to a scene?? I’ve not found anything in the docs. However, I was able to use an actor to simulate the background, at a layer in the background.

    Is there another way?

    Thanks!

  62. @Roman: You need to create a CIwGameImage resource and ad that to the resource manager also

    @Pablo: We chose 0,0 to be the centre of the screen so developers would design their game from the centre outwards, making it more compatible with different sized / aspect ratio screens. You can however set up the virtual transform manually to move the origin. Its not currently possible to set a scenes background, although that is a feature we do have planned.

    @Keith: Hoping for tomorrow or Monday for 0.3

  63. Thanks Mat.

    By the way, I was working yesterday with IwGame, trying to setup an actor with a polygon shape (kind of a half rectangular wall, like an L). Everything worked fine in the simulator, until I deployed the game to an iphone. Everytime I runned the application, I received the following error:

    Exception Type: EXC_BAD_ACCESS (SIGBUS)
    Exception Codes: KERN_PROTECTION_FAILURE at 0x00419000

    The solution I found was decomposing the “L” actor into two simple rectangular actors. After that change, everything worked perfectly.

    I don’t know if the problem is IwGame, but I wanted to tell you.

    Thanks!

    Pablo

  64. Does the JPEG loading works through the resource manager? I try putting a file.jpg in level1.group, and then putting in a .xml an referring it, and I get the following error:
    Message: Could not find handler for extension “jpg”

    By looking at the code, I can see no IwGetResManager()->AddHandler (other than for .WAV files), so I was wondering if this is normal or not?

  65. @Pablo: Box2D shapes need to be convex

    @Remz: Marmalade resource groups do not support JPEG’s I’m afraid. The next release of IwGame engine allows you to add JPEG images directly into its resources

Leave a Reply