Destroy Object by name

For questions about using Classic.

Post » Wed Aug 19, 2009 2:05 am

I see that there is a way to create object by name, but I can't find a way to destroy object by name. Essentially what I am trying to is I have three health sprite images called health1, health2, and health3. The player will have a private variable starting at 4. When the player is killed the pv is decremented by one and if not 0 the corresponding health & pv is destroyed...

However, I can't find a action to do that. Any ideas?
B
8
S
3
G
7
Posts: 835
Reputation: 5,313

Post » Wed Aug 19, 2009 2:26 am

If I am not misunderstanding, it should be in the actions for the object itself? Rather than an action under System, I mean.
"Destroy" is the name.

Depending on what you're doing, you might also be able to use three or four animation frames for your health sprite, with the animation speed set to 0, then just change the frame.

It would also be possible to destroy an object by unique ID or object ID, using "pick by comparison", but is only needed if you have multiple instances of one sprite object (all having the same name/object ID, I mean).
B
3
S
1
G
3
Posts: 82
Reputation: 1,189

Post » Wed Aug 19, 2009 11:43 am

It would be better to use four animation frames than four sprites - it makes more sense that way, and you wouldn't need a 'destroy object by name' action.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,600

Post » Wed Aug 19, 2009 8:42 pm

Thanks Ashyraccoon and Ashley. Animation frames completely skipped my mind. It makes much more sense and is simpler too!
B
8
S
3
G
7
Posts: 835
Reputation: 5,313

Post » Fri Aug 21, 2009 1:22 am

just for thread completeness: families could have also been used.
(Animation frames is probably easier)
B
3
S
2
G
4
Posts: 1,445
Reputation: 4,665


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 4 guests