Trying to get my head back into Gideros but still making some rookie mistakes I think..
I'm adding treasure to my game and everything's going well only, I can't remove the treasure body when the player collides... This is what I'm doing:
treasure = GameScene:generateTreasure()
treasure.name = "treasure"
print("I gots points! "..treasure.points)
treasure.isCoin = true
world:add(treasure, xCoord, yCoord + 15, treasure:getWidth(), treasure:getHeight()) -- x, y, w, h
if GameScene.round == 1 then
treasure = (Bitmap.new(Texture.new("images/gold1.png")))
treasure.points = 400
-- Moar points.
Then in my controls function:
for i = 1, len do -- If more than one simultaneous collision, they are sorted out by proximity
local col = cols[i]
print("Collision with "..col.other.name)
if col.other.name == "treasure" then
function GameScene:collectTreasure(treasure, points)
print("Knowledge was their treasure, their treasure was knowledge, treasure. Knowledge. Treasure = "..points)
-- Getting the same table as the one I'm adding here using world:add(treasure ...)
world:remove(treasure) -- DENIED!
treasure = nil
I'm getting the old "Item table: 0x7f850fbbfd90 must be added to the world before getting its rect. Use world:add(item, x,y,w,h) to add it first."
error, not sure what I'm doing wrong.