An ActorProxy is an actor that allows rendering of other Actors without the need to create the logic for it again.
Anything done to the Target Actor shows up in the Proxy, but anything done to the Proxy will not show up on the Target.
Def.ActorProxy{
OnCommand=function(self)
self:SetTarget( [target actor] )
end
}
There are no special attributes for this actor class.
As long as the target Actor is present, it will draw it. If it's deleted during runtime, it will stop drawing.
SetTarget
(Actors targetActor
)
Tells the ActorProxy to use targetActor
as its draw target.
-- Let's assume that I have a quad that's
-- stored via a local variable.
local myQuad = ...
-- Now, in the function, we provide the actor itself.
self:SetTarget( myQuad )
In a more direct example with full ActorFrame display:
local t = Def.ActorFrame{}
-- This will contain the handle for the BitmapText actor
-- to target.
local myText
t[#t+1] = Def.BitmapText{
Font = "Common Normal",
Text = "I am Text!",
-- Not needed for this example, but it will make sense below.
Name = "TheText",
InitCommand = function(self)
-- Now assign the handle to the variable.
myText = self
end
}
t[#t+1] = Def.ActorProxy{
-- Notice here that we're using the OnCommand.
-- This is to allow time for the BitmapText to assign the
-- myText variable its handle by the time ActorProxy attempts
-- to target it.
OnCommand = function(self)
self:SetTarget(myText)
-- To show that it's a new draw copy of the actor,
-- let's center the proxy.
self:Center()
end
}
return t
Alternatively, the handle can also be provided by calling GetChild to that same actor from the Proxy itself, by utilizing the tricks from Obtaining Childs and ActorFrame levels.
Def.ActorProxy{
OnCommand = function(self)
-- Instead of using the myText variable, we'll reach the actor using GetParent and GetChild calls.
self:SetTarget( self:GetParent():GetChild("TheText") )
-- To show that it's a new draw copy of the actor,
-- let's center the proxy.
self:Center()
end
}
GetTarget
Returns the current actor this ActorProxy is currently rendering. Returns nil
if no actor is assigned previously.
self:GetTarget()