Rekindled Phoenix Posted June 22, 2011 Share Posted June 22, 2011 My goal is to cycle all of the entities, and exclude the object that is invoking the event. The problem is that the function attached to AddHook() doesn't have a reference to the object that attached the hook. Seems the AddHook() function can only be passed a delegate (.Net reference) without parameters. (Since the objects I will be adding are not sorted in order, indexes aren't an option) function class:CreateObject(model) local object=self.super:CreateObject(model) AddHook("Flip", UpdateCycleThru(object)) --fails function object:Free(model) RemoveHook("Flip", UpdateCycleThru(object)) --fails self.super:Free() end end function UpdateCycleThru(object) -- Cycle through nodes applying a draw method, except for self end So my question is, how does an object identify itself from the rest of the objects within the scene, when the function is called outside of the Class overrides? Looking further into this issue, I may have to cycle through these objects using an external script marshaller... Quote Link to comment Share on other sites More sharing options...
Rekindled Phoenix Posted June 24, 2011 Author Share Posted June 24, 2011 Looks like the issue is resolved. Instead of trying to access the within each object, I create a 'marshaller' that does the drawing for the necessary objects. function UpdateCablesCycleThru() --model,object for k1,v1 in pairs(objecttable) do if v1.type ~= nil then if v1.type == NavTypeName then local Pos2 = CameraUnproject(fw.main.camera, k1.position) DrawPath(Pos2) end end end end function DrawPath(Pos2) --Used for each object for k,v in pairs(objecttable) do if v.type ~= nil then if v.type == NavTypeName then --inherited from 'PhoenixPath' -- Draw elements using both positions local Pos = CameraUnproject(fw.main.camera, k.position) DrawLine(Pos2.x, Pos2.y, Pos.x, Pos.y) end end end end Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.