This is an old revision of the document!
If an object is a child of a parent of object, it can be positioned relatively within that object's space. The property to use is UseParentSpace
.
Setting that to true
or both
means that the object can be positioned within the parent's space using the range (-0.5, -0.5) to (0.5, 0.5).
Start by removing the [Object]
section from the config file, and everything below it.
Define a Container
object:
[Container] Size = (400, 300) Graphic = @ Texture = pixel Color = (60.4, 76.1, 28.2) Pivot = center Scale = 1 Position = (0, 0) ChildList = PanelA
This object will be a large solid green block placed in the centre of the screen.
Also change the code to create a Container
rather than an Object
:
orxObject_CreateFromConfig("Container");
[]
Container
has a single child called PanelA
. We'll define this so that it gets created in the top left position of the Container:
[PanelA] Graphic = @ Texture = pixel UseParentSpace = both Pivot = center Scale = 0.5 Color = (96.1, 56.9, 35.7) Position = (-0.5, -0.5, -0.1)
[]
PanelA
is a brownish block and is placed centred on the top left corner of the Container. It is using UseParentSpace so that is uses the position and scale of the parent. The Scale
is set to 0.5 so that the panel becomes half the size of the parent Container.
To emphasise the range of positions, define a number of TestPoints:
[TestPoint1] Graphic = @ Texture = pixel UseParentSpace = both Pivot = center Scale = 0.25 Color = (50, 50, 50) Position = (-0.5, -0.5, -0.1) [TestPoint2] Graphic = @ Texture = pixel UseParentSpace = both Pivot = center Scale = 0.25 Color = (100, 100, 100) Position = (-0.25, -0.25, -0.1) [TestPoint3] Graphic = @ Texture = pixel UseParentSpace = both Pivot = center Scale = 0.25 Color = (150, 150, 150) Position = (0.0, 0.0, -0.1) [TestPoint4] Graphic = @ Texture = pixel UseParentSpace = both Pivot = center Scale = 0.25 Color = (200, 200, 200) Position = (0.25, 0.25, -0.1) [TestPoint5] Graphic = @ Texture = pixel UseParentSpace = both Pivot = center Scale = 0.25 Color = (250, 250, 250) Position = (0.5, 0.5, -0.1)
Then add these testpoints to the ChildList
of PanelA
:
[PanelA] Graphic = @ Texture = pixel UseParentSpace = both Pivot = center Scale = 0.5 Color = (96.1, 56.9, 35.7) Position = (-0.5, -0.5, -0.1) ChildList = TestPoint1 # TestPoint2 # TestPoint3 # TestPoint4 # TestPoint5