Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Really weird object:remove behaviour
Started by cableguyp Feb 15 2019 05:43 PM

1 reply to this topic

Best Answer cableguyp , 15 February 2019 - 06:29 PM

I was stupid and had tiles spawn where they wouldnt be deleted off screen. It's fixed...was just 1 number change -_-

[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

cableguyp

[GLOBAL: userInfoPane.html]
cableguyp
  • Observer

  • 8 posts
  • Corona SDK

Hi, so I am trying to make a function that will delete these "tiles" from the mapGroup if they get too low or don't belong there based on my algorithm.

 

So I'm using this at the moment to delete the tiles if they get too low

for i = mapGroup.numChildren, 1, -1 do
    if gameover == false then
      if hasCollided(mapGroup[i], character) then
        end_game()
      end
      if hasCollided(mapGroup[i], deleteSpace) then
        mapGroup:remove(i)
        mapGroup[i] = nil
      end
    end
  end

And you think that it would work good except that it leaves these "ghost" tiles that take up an index value. So I end up with 200+ tiles in the displayGroup that arn't actually there and cant do anything. Would anyone know why these empty "tiles" are left over?

 

Also when I try another way of removing the tiles when they get too low like

for d = mapGroup.numChildren, 1, -1 do
    if mapGroup[d].y > 1400 then
        mapGroup:remove(d)
        mapGroup[d] = nil
    end
  end

It only works on the first loop of the for loop but once it is called again it does not remove the tiles. It only seems to remove them on the first time it is run but not after that. Thanks if you can help!



[TOPIC: post.html]
#2

cableguyp

[GLOBAL: userInfoPane.html]
cableguyp
  • Observer

  • 8 posts
  • Corona SDK

  Best Answer

I was stupid and had tiles spawn where they wouldnt be deleted off screen. It's fixed...was just 1 number change -_-




[topic_controls]
[/topic_controls]