Destroyed

For questions about using Classic.

Post » Sat May 02, 2009 2:04 am

Is there an event to check if an object is destroyed our not? Some like "Have all objects been destoryed?" or something?
B
11
S
3
G
8
Posts: 473
Reputation: 4,569

Post » Sat May 02, 2009 2:16 am

I don't think there is something specifically for this. The first thing that comes to mind would be object is on screen, but that wont work if screen size is smaller than the layout. I would suggest a private variable, something like on creation set pv to 1, and on destroy set pv to 0, then if pv =0....
Image Image
B
161
S
48
G
91
Posts: 7,358
Reputation: 67,271

Post » Sat May 02, 2009 2:55 am

If you want to know if all objects of a certain type have been destroyed, you could always do a system compare on the object count, which is, I believe, like this: yourobject.Count
Moderator
B
98
S
37
G
19
Posts: 1,584
Reputation: 17,817

Post » Sat May 02, 2009 7:10 am

Linkman's right, just check if the count equals 0.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Sat May 02, 2009 7:26 am

If there are no objects, the debugger will pop a warning message and return 0. It is not the most elegant way and potentially annoying if you have a large project that you are debugging regularly.

I'd suggest something like:

+Always
>set 'Number' to CountMatching("Sprite")

It won't return the error. It is SOL sensitive, as well, so you can put it within context.
B
62
S
21
G
12
Posts: 1,910
Reputation: 13,155


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 3 guests