Obtaining Childs and ActorFrame Levels
When using Actors, you can use self:GetParent()
and self:GetChild()
to get elements from other ActorFrames or Actors.
self:GetChild()
can only be used by ActorFrames.
You can think of an ActorFrame as a tree of objects. This is the original table. And now you’ve called GetParent on the ActorProxy.
Def.ActorFrame{
Def.BitmapText{ Name="MyText" },
* Def.ActorProxy{
OnCommand=function(self)
self:GetParent()
end
},
}
graph LR AF[Def.ActorFrame] --- BT(Def.BitmapText) & AP(Def.ActorProxy) style AF stroke-width:4px style BT stroke-width:4px style AP fill:#585,color:#fff,stroke-width:4px
When calling it, you go back up a level, which in this case,
it will become ActorFrame.
graph LR AF(Def.ActorFrame) --- BT(Def.BitmapText) & AP(Def.ActorProxy); style AF fill:#585,color:#fff,stroke-width:4px style BT stroke-width:4px style AP stroke-width:4px
In this new location, we get the MyText
actor, which can be achieved by calling the GetChild command, and can also return back to the ActorProxy, as we’re now in a level that can get both actors (shown in orange).
Def.ActorFrame{
* Def.BitmapText{ Name="MyText" },
Def.ActorProxy{
OnCommand=function(self)
self:GetParent():GetChild("MyText"):spin()
end
},
}
graph LR AF(Def.ActorFrame ) --> BT(Def.BitmapText) & AP(Def.ActorProxy); style AF fill:#f85,color:#fff,stroke-width:4px style BT fill:#585,color:#fff,stroke-width:4px style AP fill:#585,color:#fff,stroke-width:4px
Def.ActorFrame{
OnCommand=function(self)
-- If we want to get to the BitmapText, we'll need to get
-- the second entry on the ActorFrame.
self:GetChild("")[2] -- returns the BitmapText actor.
end,
Def.Sprite{},
Def.BitmapText{}
}