Dali Docs (Live Example)

Downloading...

Positioning Actors

An actor inherits its parent's position. The relative position between the actor & parent is determined by 3 properties:

  1. PositionExample. This Vector3 property defines a point relative to the parent actor's area.

The default is "top-left", which can be visualized in 2D as (0, 0), but is actually Vector3(0, 0, 0.5) in the 3D DALi world. The actor's position is relative to this point.

// to change parent origin to the centre
myActor.positionExample = [0.5, 0.5, 0.5];
		  


  1. AnchorPoint. This Vector3 property defines a point relative to the child actor's area.

The default is "center", which can be visualized in 2D as (0.5, 0.5), but is actually Vector3(0.5, 0.5, 0.5) in the 3D DALi world. The actor's position is also relative to this point.

// setting anchor point to the centre
myActor.anchorPoint = [0.5, 0.5, 0.5];
		  


  1. Position. This is the position vector between the parent-origin and anchor-point.

Therefore by default, an actors position is the distance between its center and the top-left corner of its parent.

An actor added directly to the stage with position (X = stageWidth0.5, Y = stageHeight0.5), would appear in the center of the screen. Likewise an actor with position (X = actorWidth0.5, Y = actorWidth0.5), would appear at the top-left of the screen.

Note that since DALi is a 3D toolkit, this behaviour is the result of a default perspective camera setup.




The parent in the example already has a parentOrigin [0.5, 0.5, 0.5] so a zero position displays in the centre. This can be changed below