Hi, I’m having a problem with hitTestPoint. Apparently I don’t know how to use it. The code below (which is the entire code in the project) works fine as long as the two commented lines are commented out. It loads normally and if I click anywhere, the print function prints out as expected.
If I uncomment those two lines, the program runs fine at first, but if I click on the image I get:
Uploading finished.
main.lua:3: attempt to index local 'event' (a nil value)
stack traceback:
main.lua:3: in function
I don’t understand why there are no values for “event”. Can someone help?
Code:
local image1 = Bitmap.new(Texture.new("images/randy.png", true))
function image1:printThis(event)
--if image1:hitTestPoint(event.x, event.y) then
print("printing function")
--end
end
image1:addEventListener(Event.MOUSE_UP, image1.printThis)
stage:addChildAt(image1, 1)
Comments
Option 1, turn ':' into '.' on the handler
I've always had problems knowing the difference bewteen the dot operator and the colon operator - instance vs method stuff. I guess I need to read about those again in the lua documentation.
Thanks again.
Likes: SinisterSoft, Apollo14, antix