Ok, I have polyominos. Each tile has it’s own collisionobject on it. I’m using a trigger. I also have a tilemap where if it lands on certain objects the tile in the polyomino gets deleted when released. This is working perfectly.
However, my issue is I want to be able to drop the polyomino onto another polyomino. And then delete the one that is already laid down. Not the entire polyomino but just the tiles that are overlapped.
The issue appears to be the first one to send the mesasge wins OR they both send the message and they both get deleted. Or random tiles will be deleted.
My current setup is as follows:
group: bottom_tile
Mask: tile, top_tile
Upon drag I change the group to top_tile:
local function make_collision_group_top(self)
self.dragging = true
physics.set_group("#collisionobject_top_tile", "top_tile")
print("make top tile: ", physics.get_group("#collisionobject_top_tile"))
end
Then on drop I reset it back to bottom_tile:
local function reset_collision_group(self)
physics.set_group("#collisionobject_top_tile", "bottom_tile")
print("reset tile: ", physics.get_group("#collisionobject_top_tile"))
end
It appears the trigger doesn’t reliably work for enter and exit. I have it printing statements and it will show it entering but not exiting. Sometimes if I touch two square tiles at once by sliding in sideways…it will capture both trigger events. But then when I slide away it will only report one trigger exit event.
Here’s my current on_message if statements:
if message_id == hash("trigger_response") then
--pprint(message)
if message.own_group == hash("top_tile") and message.other_group == hash("tile") and message.enter then
self.delete_me = true
elseif message.own_group == hash("top_tile") and message.other_group == hash("tile") and message.enter == false then
self.delete_me = false
elseif message.own_group == hash("top_tile") and message.other_group == hash("bottom_tile") and message.enter then
self.delete_other = message.other_id
self.delete_me = false
print("delete other one: " , message.other_id)
elseif message.own_group == hash("top_tile") and message.other_group == hash("bottom_tile") and message.enter == false then
self.delete_other = nil
self.delete_me = false
print("Make other NIL")
end
end
One more odd thing. I have to put both bottom_tile and top_tile in the mask to make the trigger work on that portion of code. The first two if statements work great as “tile” is an object on my tilemap (like rocks) that I want to delete the poly tile. Once again those triggers are perfect and everything is great. I just can’t get the way to make it delete the bottom (already laid) poly tile reliably.