User Tools

Site Tools


en:tutorials:objects:literals_for_objects

This is an old revision of the document!


Position literals to align with Parent Objects

Literal Positions add flexibility to the Position property for objects (and incidentally for spawners as well, but in a less extensive manner as spawners don't have a Pivot).

They should be useful for positioning an object relative to its parent, without doing some calculations manually.

When a Parent is defined for an object, you can use the same literals for Position as with Pivot to align object inside parent's borders.

The global form is:

  Position = [pivot's override ->] Position's in parent space

Here's a basic setup with one rectangular parent (green) and one rectangular child (red):

[Parent]
Color     = lime green
Size      = (400, 300)
Pivot     = center
ChildList = Child
 
[Child]
Color     = orange red
Size      = (200, 150)
Pivot     = center
Position  = (0, 0, -0.1)

And its result (nothing unusual so far):

The Pivot of each rectangle will be highlighted with a small lighter colored square Let's try a few things and see the results

[Parent]
Pivot     = center
 
[Child]
Pivot     = center
Position  = top right

[Parent]
Pivot     = center
 
[Child]
Pivot     = top left
Position  = top left

[Parent]
Pivot     = left
 
[Child]
Pivot     = bottom right
Position  = top left (10, 10, -0.1)

[Parent]
Pivot     = left
 
[Child]
Pivot     = bottom left
Position  = bottom right -> bottom left

[Parent]
Pivot     = left
 
[Child]
Pivot     = (20, 20)
Position  = (100, 100) -> bottom left -0.1

[Parent]
Pivot           = left
 
[Child]
UseParentSpace  = position
Pivot           = center
Position        = top right -> (0, 0.1)

[Parent]
Pivot     = left
 
[Child]
Pivot     = (20, 20)
Scale     = 0.5
Rotation  = 30
Position  = bottom right -> bottom left -0.1

One last for the road….

[Parent]
Pivot           = left
Rotation        = -30
Scale           = 0.5
 
[Child]
UseParentSpace  = position
Pivot           = top right
Scale           = 2
Rotation        = 30
Position        = bottom right -> bottom 

en/tutorials/objects/literals_for_objects.1628511912.txt.gz · Last modified: 2021/08/09 05:25 (3 years ago) by sausage