Hi
I’ve been making a card game but i ran into issues with removing display objects.
I’ve made a hole in the sprite of the cards to see the background to check that the display objected being removed its actually gone but its still there. I dont really understand what i’m doing wrong.
Here is the code for the creation of the cards and its removal:
function drawEntities()
for key, value in pairs(cells) do
local image
local entity = value[1]
local num = value[2]
local x = value[3]
local y = value[4]
if entity == 'enemy' then
drawBlank('enemy',x,y,key,background)
local image = display.newImage(spritesheet,num)
image:scale( imgscale, imgscale )
image.anchorX = 0
image.anchorY = 0
image.x = x
image.y = y + math.floor(RECT_H / 4)
cells[key]['sprite'] = image
elseif entity == 'player' then
drawBlank('player',x,y,key,background)
local image = display.newImage(playersprite,num)
image:scale( imgscale, imgscale )
image.anchorX = 0
image.anchorY = 0
image.x = x
image.y = y + math.floor(RECT_H / 4)
cells[key]['sprite'] = image
end
end
end
function attack(cell,playerPos)
display.remove(cells[playerPos]['blank'])
display.remove(cells[playerPos]['sprite'])
display.remove(cells[cell]['blank'])
display.remove(cells[cell]['sprite'])
local x1 = cells[cell][3]
local y1 = cells[cell][4]
local x2 = cells[playerPos][3]
local y2 = cells[playerPos][4]
local adjacent = neighbours[cell]
emptyPlaces[playerPos] = {x2,y2}
cells[cell] = {'player',1,x1,y1}
cells[cell]['enemies'] = adjacent
currPlayerpos = cell
end