How do I delete all instance of a particular type?

Get help using Construct 2

Post » Fri Mar 23, 2012 2:55 pm

I have now tried several way to delete all instances of a object, but can't seem to get it to work.

What is the best way to remove all instances of a object from the game.

Example:

The game of chess is over and and wanner remove all the pawns so I can insert them again for the next game.
B
5
G
1
Posts: 31
Reputation: 1,012

Post » Fri Mar 23, 2012 3:01 pm

For each "Object" -> Destroy Object?
B
42
S
9
G
6
Posts: 437
Reputation: 5,626

Post » Fri Mar 23, 2012 3:04 pm

Event for removing all instances.

Add event (system --> pick all)
Choose instance.
Add action (destroy)

If this wont work then posting a capx would be helpfull for those whith answers.

Goodluck!
B
56
S
20
G
13
Posts: 778
Reputation: 13,204

Post » Fri Mar 23, 2012 4:38 pm

This removes the visually from the game, but if I do a For each "Object" -> someAction right after they are still there.

So if I add 10 objects, foreach object destroy, add 10 object and finally foreach object something, the loop iterates 20 times, even thought I only see 10 objects on the screen.
B
5
G
1
Posts: 31
Reputation: 1,012

Post » Fri Mar 23, 2012 4:39 pm

[QUOTE=Savvy001] Event for removing all instances.

Add event (system --> pick all)
Choose instance.
Add action (destroy)

If this wont work then posting a capx would be helpfull for those whith answers.

Goodluck![/QUOTE]

Ill try to post an example..
B
5
G
1
Posts: 31
Reputation: 1,012

Post » Fri Mar 23, 2012 5:03 pm

[QUOTE=mindgear] [QUOTE=Savvy001] Event for removing all instances.

Add event (system --> pick all)
Choose instance.
Add action (destroy)

If this wont work then posting a capx would be helpfull for those whith answers.

Goodluck![/QUOTE]

Ill try to post an example..[/QUOTE]

Here is an example:
http://dl.dropbox.com/u/19522040/destroyProblem.capx
B
5
G
1
Posts: 31
Reputation: 1,012

Post » Fri Mar 23, 2012 5:11 pm

Here is your corrected example

What's the point of spawning instances and destroying them in the same row anyway ?

Also it had more to see with the order and how events work.
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: 7,000
Reputation: 57,795

Post » Fri Mar 23, 2012 6:13 pm

[QUOTE=Kyatric] Here is your corrected example

What's the point of spawning instances and destroying them in the same row anyway ?

Also it had more to see with the order and how events work.[/QUOTE]

There is no point! :-) It was just an example to illustrate that I got an unexpected result from performing a series of actions.

If i create x object, iterate and destroy them, I should end up with zero objects. My example just demonstrates that this is not what happens.

B
5
G
1
Posts: 31
Reputation: 1,012

Post » Fri Mar 23, 2012 6:14 pm

Using a family maybe?
B
28
S
2
Posts: 69
Reputation: 1,491

Post » Fri Mar 23, 2012 6:37 pm

[QUOTE=mindgear] [QUOTE=Kyatric] Here is your corrected example

What's the point of spawning instances and destroying them in the same row anyway ?

Also it had more to see with the order and how events work.[/QUOTE]

There is no point! :-) It was just an example to illustrate that I got an unexpected result from performing a series of actions.

If i create x object, iterate and destroy them, I should end up with zero objects. My example just demonstrates that this is not what happens.

[/QUOTE]

Here is a different version of my example that works.

http://dl.dropbox.com/u/19522040/destroyProblem.capx

I understand why this works, but I'm still puzzled that the first version did not.... Well Ill try to make this work in my game.... Thanks for the feedback/help.
B
5
G
1
Posts: 31
Reputation: 1,012

Next

Return to How do I....?

Who is online

Users browsing this forum: farfetchd83, Laurent, makkancs and 23 guests