Found a bug in the raycast. Data is not optional. If data is missing, function arguments are shifted to the right.
but, how it works below:
function ray(data, fixture, hitX, hitY, vectX, vectY, fraction)
print("(x, y)"..hitX,hitY)
end
ray1 = stage.world:rayCast(x1, y1, x2, y2, ray, {})
and how its not work:
function ray(fixture, hitX, hitY, vectX, vectY, fraction)
print("(x, y)"..hitX,hitY)
end
ray1 = stage.world:rayCast(x1, y1, x2, y2, ray)
Comments
I couldn't catch the bug. On my side both
Here is my full test code:
createBox(100, -30)
createBox(190, -30)
Output:
table: 078B3D98 60 240 -1 0 0.1875
nil table: 078B2230 150 240 -1 0 (its arg+1 bug)
my data table: 078B3D98 60 240 nil nil 0.1875
my data table: 078B2230 150 240 nil nil 0.46875
Likes: atilim
https://play.google.com/store/apps/details?id=com.uglygames.slug
I am trying to use rayCast with a class-based structure, and I am still seeing this bug. Here is an example setup:
main.lua
If I remove the class-based implementation and switch everything to a simple script, it works fine. Example:
main.lua
Am I missing something or is this a bug?
if you define function as method of class like this (with colon):
To bypassed that (like in all listeners), you would need to provide reference to instance as self when you add your listener as data parameter, like this:
Thank you for clarifying that! My apologies for thinking it was a bug.
https://play.google.com/store/apps/details?id=com.uglygames.slug
but.. but why so? why checking 1,2, and coordinate 2 is (x,y). but if coordinate 2 is (x,y+n), then checking is 2,1.. and if (x,y+m) then 1,2 again.. I'm stumped
https://play.google.com/store/apps/details?id=com.uglygames.slug