Hi,
I am trying to create a function that creates display text on touch and deletes it on release, but I am getting a runtime error “attempt to index field ‘?’ (a nil value)”. I am also using composer.
If I comment out this line the code runs, but of course doesn’t delete the text
[lua]
touches[touchID].coords:removeSelf()
[/lua]
full code here:
[lua]
local function storeTouches(event)
local touchID = tostring(event.id)
if event.phase == “began” then
touches[touchID] = {}
touches[touchID].coords = {}
touches[touchID].x = event.x
touches[touchID].y = event.y
touches[touchID].coords = display.newText(touchID…" = “…event.x…”,"…event.y,0,0,system.nativeFont,15)
touches[touchID].coords.x = event.x
touches[touchID].coords.y = event.y - 20
elseif event.phase == “moved” then
elseif event.phase == “ended” then
touches[touchID].coords:removeSelf()
touches[touchID] = nil
end
end
[/lua]
and further down
[lua]
Runtime:addEventListener( “touch”, storeTouches )
[/lua]