A
A
Afafks1231321321652020-02-01 14:55:22
Corona SDK
Afafks123132132165, 2020-02-01 14:55:22

How to delete objects in corona?

I have a game for the crown. And I need to delete objects that have gone beyond the screen, how to do this? I rummaged through the Internet, but still I couldn’t do it, what should I do?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dollar, 2020-02-02
@dollar

obj:removeSelf();
Plus, you need to remove all references to this object so that the garbage collector can clean it from memory. More or less like this:

event.object1:removeSelf();
event.object1 = nil;

In general, it depends on the game code. That is, if there are lists of objects somewhere, then they also need to be deleted. In short, the general principle is this - just assigning nil to a variable:
obj = nil;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question