lua - collision detection doesn't work inside scene:show -
I am trying to detect conflicts on two objects within my view: Show
Function
This is my first object set, on which the collision listener
for i = 1, table.maxn (layout.playgrid) physics .addBody (leftholes [I], "static") Visual group: insert (3, lefthole [i]) lefthole [i] .name = "hole" lefthole [i]: Advent Listener ("Collision", LIS) Physics Adbodi (Rigolay [ii], "Stable" Endent Listener ("Collision", LIS) Physics, Eddy (Toofol [I], "Static") Senior Group: Insert (3, topholes [i]) topholes [i]. AddoventListener ("collision", lis) physics. Addboard "Collision", lis) [i] .name = "hole" end
and this object that will collide with the hole object
= Display. NYMI ("Assets / Hand page", 350, 490) Hand Name = "Hands" Physics. ADDBD (Hand, "Stable")
and My Conflict Listener
Local Function lis (Incident ) If event.phase == "start" and event.object2.name == "hand" then print ("detected") local function tr (trans) = display .image ('assets / gray page', 'indesatoouter corridant' (Layout. Finals, layout.finili, layout.finlines, bogus)) physics.edbody (trans, "static") visual group: insert tax (Trans) hand: ToFront () End end term
Just check whether you runtime Event clutter is adding to your collision listener.
If you do not add your collision with Runtime Event listeners, then your address will not be found.
event) If print (event.phase == "started") then print ("Started:" .. event.object1.myName .. "and" .. event. Object2.myName) elseif (Event .phase == "Finish") Then print ("Finish:" .. event.object1.myName .. "and" .. event.object2.myName) End End
Runtime: AddEventListener ("collision", but on)
Comments
Post a Comment