Hi,
I'm having this issue and i'm getting desperate about it...
I have a game where i create many blocks and make them go from right to left via parallax effect and between them there's space for the player to draw a bridge so the character would not fall. When they exit the screen i destroy the blocks and create the new one on the right side.
I also have a pause screen from where i can exit the game and return to the title screen. My problem is that whenever i exit the scene, the physical bodies of the blocks somehow stays on the stage, even though i'm not at the game scene anymore, that is causing the game to crash if i try to draw something over the body that is already there.
How can i destroy those remaining bodies? I managed to destroy the player's character one, but i can't seem to be able to reference the bodies from the bridge and the blocks....
I tried to upload my .lua files but the forum refuses to let me lol So i'm pasting them here...
Please, any help would be deeply appreciated.
Comments
This is the function that creates the blocks
https://github.com/gideros/gideros
https://www.youtube.com/c/JohnBlackburn1975
attempt to index global 'block' (a nil value)
Sorry for taking so long... any help would be deeply appreciated.
attempt to index global 'block' (a nil value)
generally this error will come when you are trying to access object which is already removed or that is a local inside any function[and hence not accessible where you are trying to access] if you are sure that it is not removed then you might have declared it as local in any other function try to remove that local and make that global after this every thing should work fine
also in the case you want to delete everything onExitBegin use this
Likes: AxlFlame
Assuming its that, I got another error:
"attempt to perform arithmetic on field 'removeAt' (a nil value)"
removeAt is a property of block, and after I tried to change block to global aparrently it started to receive nil...
That block.removeAt is located inside the NewBlock function I pasted here, halfway, right before the block onEnterFrame.
Btw, thanks for the advice regarding destroying everything! It works perfectly... except for the block of course =/
That said I tried to use this to destroy the bridge:
Body is already destroyed.
And the error points to this part: