Someone asks me if it was possible to create this type of game with the Citrus Engine, absolutely! So let’s go for a quick tutorial.

Firstly, all hails to Lorenzo! The physics hills and the sprites creation come from his algorithm.
This is what you will get : demo.
To see the physics debug view, open the console with the key tab, then write :

set nape visible true

And press enter. You will see Nape’s debug view and the hero. You can jump with a click.
All the source code is accessible on the new CE’s GitHub for examples.

I won’t explain the algorithm. If you have any questions on it, ask Lorenzo. He will certainly answer better than me. However I’ll explain how it has been added to the Citrus Engine.

Now let’s focus on the Hills creation. Hills is a new Nape’s object added to the Core of the Citrus Engine. It extends NapePhysicsObject. Since the Citrus Engine separates logic/physics from view/art, we don’t want to manage graphics in this core class. So we remove all the content related to graphics :

To have exactly the same feeling that Tiny Wings there is always lots of work to achieve :
– make the terrain more rolling.
– don’t apply a linear velocity to your hero, just a basic force and then change its mass between screen touched or not.
– create nice graphics using procedural palettes algorithms.

When I’ve some time, I will work on the Box2D version thanks to Emanuele’s tutorial and polish this version.

Hi I’ve been working on a game that implements this tutorial but I’m running into a problem where I don’t see the fill colour of the hill slices. I have to turn on the visibility of nape in order to see where my hills are going. Everything else works perfectly!

When I run the example, based on the latest updates, I get this error:

_nape is null

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Walls::WallElement/_createSlice()
at Walls::WallElement/_prepareSlices()
at Walls::WallElement/initialize()
at citrus.core::CitrusObject()
at citrus.objects::APhysicsObject()
at citrus.objects::NapePhysicsObject()
at Walls::WallElement()
at GameState/initialize()
at citrus.core.starling::StarlingCitrusEngine/handleEnterFrame()

I tried moving the _prepareSlices call to an override of addPhysics. This causes a different error once my hero intersects with the wall: ‘b’ is null in NapeContactListener.as: onInteractionBegin()

Hey Aymeric, I removed some of the extra calls to update, are there special rules around this? I notice that your texture class’ update method is getting called from the StarlingState.

Changing the updates didn’t fix my bug, but I finally found it! When changing the hills to walls I removed this line:_body.userData.myData = this;
I dropped it back in and everything is back to normal. Thanks for your help!

Hey, great tutorial! This and the original from Lorenzo helped a lot! I´m totally new to starling and citrus. How to make the hero follow the terrain inclination? Like, if it were a car, it should adapt itself to the floor. Do citrus create a nape space by default?