Hi,
I have runtime listener that is listening for touches anywhere to the screen. On touch it rotates a display object. The trouble is I have the display object set to be removed on collision with another object. When this happens while I am rotating the object I get an error because I’m trying to rotate an object that no longer exists. I’m not sure how to resolve the issue. Below is my rotate function:
local function rotate(event)
local t = beans[#beans]; #My display object
if (event.phase == "began") then
touchStart = event.y
end
if (event.phase == "moved") then
if (event.y \< touchStart) then
if(t ~= nil) then
t:rotate( -2 );
end
end
if (event.y \> touchStart) then
if(t ~= nil) then
t:rotate( 2 );
end
end
touchStart = event.y;
end
end
Runtime:addEventListener("touch", rotate);
[import]uid: 31694 topic_id: 22961 reply_id: 322961[/import]