Destroying objects

Get help using Construct 2

Post » Mon Oct 10, 2011 3:55 am

HEy i am making a mechanic for this game i am creating and i need to destroy a single instance of a object on screen and not all of them.

capx

In depth: When you hit space you create bubbles(Circles) and they rise up. What i want to do is destroy the bubble after t is created for a certain amount of time. If there are multiple of that said bubble on the screen i don't want all of them to be destroyed but only 1 at a time depending on how long they have been alive.
B
5
G
3
Posts: 25
Reputation: 1,275

Post » Mon Oct 10, 2011 5:06 am

Create an instance variable "lifespawn" to your bubbles object.
Either set it to 0 and increment it by 1 every frame/tick until it reaches 120 for example (120 = 2 seconds since the app runs at 60 fps).
Or either set it to your max value, decrement it by 1 each frame and when it reaches 0 then you know you want to destroy that bubble.

In one case or another, make a condition Bubbles.lifespawn = End_Value
+ action Bubbles.destroy (this will pick only the bubbles which lifespawn reached their final value).

This is like the health mechanic in the Beginner's guide, page 6, private instances section
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,999
Reputation: 57,793

Post » Mon Oct 10, 2011 2:02 pm

Thanks, i will ake a look at what you have said and linked. :)


Ok got it working. I was thinking how instance variables work wrong. Now that i kno how they work it will be a lot easier.komes2011-10-10 14:07:56
B
5
G
3
Posts: 25
Reputation: 1,275


Return to How do I....?

Who is online

Users browsing this forum: 99Instances2Go and 22 guests