Introduction
As some may be aware of, the latest beta introduced the first pieces of Construct's own implementation of a scene graph.
Some people are excited, for good reasons. But I read from quite a few that have no idea what the fuss is all about. Allow me to explain...
First, what is a scene graph?
Scene graph is a fancy name for a tree structure, in which a root parent object can have children and then those, children of their own. A quick search in Google let's me find an image to convey this, here it is.
In the context of Construct, this new feature allows you to establish that kind of relationship between plugin instances (at the moment only Sprite instances).
With that hierarchy created, it is possible for the runtime to calculate translations, rotations and scaling of a child based on that of it's parent.
- Example 1: a parent is translated in X for 100 pixel, all it's children will follow to ensure they maintain their relative position to the parent.
- Example 2: a parent rotates then all children will adjust their positions to rotate around the parent's origin as well as adjust their own rotation.
- Example 3: a parent changes it's scale, all children will adjust their positions as well as scale in response to the parent's changes.
The most common case would we for any of this things to happen at any given point and Construct will calculate the correct position, rotation and scale for all the instances involved.
Keep in mind that all child transformations occur around the parent's origin. I think this is better demonstrated by this small example project.
https://www.dropbox.com/s/etwun316sox4lne/SceneGraphExample.zip?dl=0
New runtime actions
The latest beta introduced 3 new actions, Add Child, Remove Child and Remove From Parent. To make things easier on ourselves, at the moment these are only supported on the Sprite plugin, as the feature matures and we iron out bugs and implement user feedback more plugins will be supported.
- Add Child: This one is used to add a child to another instance. It's pretty straight forward. When an instance is added as a child of another one there is no immediate change, it is only when the parent is modified that the child will respond accordingly.
- Remove Child: This is pretty straight forward as well, remove the specified child from the picked parent.
- Remove From Parent: This is similar to Remove Child, but allows you to remove the picked instance from it's parent, without knowing to which instance it belongs.
I think this is it for now, I will update this thread as more features are added. If you have any questions I'll try to answer them here.