Isaac – Working with scenes part 2

Isaac 2Dis a C++ framework based on SFML(Simple and Fast Multimedia Library) and BoostC++ Libraries that provides support for an easy development and understandable(flexible) structure even in complex scenarios for application and games. Also, Issac it is a multi-platform library, your applications or games can compile and run on the most common operating systems: Windows, Linux, Mac OS X.

Hello to the “Working with scenes part 2” tutorial, please make sure that you read all the previous tutorials before starting reading this one. In this article I’m going to continue with the scenes that we developed in the last tutorial in order to introduce some new concepts that are available in Isaac.

Transient Data

Transient data are variables that are available for all the scenes. A scene can ask for a transient data or can update a transient data for another scene. This variables are hold in an any structure that is available in boost. Let’s say that from the SceneTwo we want to control the motion speed for the rectangle that is present in the SceneOne. In order to do this we need to declare a transient data in the StaticAspect class:

Now we have a variable that is transient (it is available for all the defined scenes), we are going to use this variable in the SceneOne for the rectangle motion. So, let’s see how we can do this. Go to the source code of the SceneOne and get the transient data:

Now every time the second scene it will activate, the rectangle speed it will increase, making the rectangle to move faster and faster with every instance of “SceneOne”. This is how you can work with transient data in Isaac. Is important to know that a transient data can be represented by any kind of variable, in this example we used a double, but you can use any kind of data types that you want.

Father Scenes

This is a new concept that you can use in your projects. A scene can be a father scene for other scenes. The father scene will be visible when the scenes that are calling him father are visible. In other words if the scene that is displayed has a father scene, that scene it will be also visible. A father scene can also have a father scene and that father scene can also have a father scene 🙂 (Inception like).

So, let’s try to make an example, first of all create a new scene and name it “SceneThree”, the header file:

Nothing special with this one either, just init the rectangle and draw it somewhere on the screen. Now, we are going to set this scene as father scene for the other two scenes that we have defined. In order to do this, go to the StaticAspect class and modify :

By doing this the rectangle that we drew on the third scene it will be available when SceneOne it will be active and also when SceneTwo it will be active. This is how the father states are working in Isaac. Hope you like it, see you on the next tutorial. Bye 🙂