Object after Destroy (feature request)

Discussion and feedback on Construct 2

Post » Fri Apr 24, 2015 9:00 pm

Is there a way to evaluate existence of an object after Destroy action. If not could we have anything similar.

What I am trying to accomplish, imagine you have n objects obj1…n, on first touch you destroy obj1, on second touch you check if there is no obj1, destroy obj2, on third touch you check for obj2 and destroy obj3...
Right now you can’t do this, for example I tried this
On Touched
obj1 Is Visible -> obj1.Destroy

obj2 Is Visible -> obj2.Destroy
obj1 Not Is Visible

obj3 Is Visible -> obj3.Destroy
obj2 Not Is Visible

And it won't work because destroyed object doesn't exist anymore so condition 'Is Visible' or 'Not Is Visible' is equally false and can't be used.
So my question is, can it be done with current conditions, or can we have 'Is Exist' or similar conditon to evaluate.
B
58
S
9
Posts: 22
Reputation: 3,953

Post » Fri Apr 24, 2015 9:07 pm

You could use else.

obj1 is visible -> obj1.destroy

else
obj2 is visible -> obj2.destroy

else
obj3 is visible -> obj3.destroy

...
B
55
S
29
G
19
Posts: 1,520
Reputation: 25,650

Post » Fri Apr 24, 2015 9:14 pm

for some more control you can also use compare two values system condition and use obj1.count=0

https://www.scirra.com/manual/133/common-expressions

Count
The number of instances of the object type.
B
42
S
17
G
2
Posts: 850
Reputation: 6,209

Post » Fri Apr 24, 2015 9:33 pm

I just made an example problem to illustrate one possible usage. It is not unsolvable problem. In my case I solved similar problem with an array to keep track of objects, but I think it would be better if there is a way of checking existance of an object.

I like the Count solution, didn’t think of it, would like the ‘Is Exist’ better, image representation in code and all that, but it should do.
Thanks.
B
58
S
9
Posts: 22
Reputation: 3,953


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 9 guests