sprite:alphaCollision errors with "failed expression"

Simulator 1.1.0

Sprites

  • Group 1
    • 8 × 8
    • 10 sprites
  • Group 2
    • 864 × 352
    • 1 sprite
  • Notes
    • setGroups and setCollidesWithGroups are set
    • CollideRect is full size of all images
      • sprite:setCollideRect(0,0,sprite:getSize())

Code

	local collisions = gfx.sprite.allOverlappingSprites()

	for i = 1, #collisions do
		local collisionPair = collisions[i]
		local sprite1 = collisionPair[1]
		local sprite2 = collisionPair[2]
		-- do something with the colliding sprites
		if sprite1.alphaCollision(sprite2) then
			print("collide")
		end
	end

Error

main.lua:203: failed expression: ((!(((((((to))->tt_)) & 0x0F)) == (0)) || to != &(L->l_G)->nilvalue)) && "invalid index" at /Users/buildbot/Developer/ci-builds/8D7YLVpW/0/playdate/PlayDate/Core/minilua/lapi.c:233
stack traceback:
	[C]: in field 'alphaCollision'
	main.lua:203: in function <main.lua:172>

Line 203 is the call to sprite.alphaCollision()

Ugh, how embarrassing. :flushed:

Should be a colon:

Still, I think the error should be caught and/or be made more descriptive.

1 Like