How do I Remove a number of instances? [SOLVED]

Get help using Construct 2

Post » Sat Nov 28, 2015 9:13 pm

B
14
S
1
Posts: 66
Reputation: 771

Post » Sat Nov 28, 2015 9:15 pm

You used the wrong condition. It's pick random instance.
Winstratos on:

Twitter
Facebook
Tumblr
B
12
S
5
G
1
Posts: 23
Reputation: 1,602

Post » Sat Nov 28, 2015 9:19 pm

Paulo Cezarino wrote:You used the wrong condition. It's pick random instance.



What do you mean? I want to remove 20 random instances. Code says that remove instance 0 every time.. isn't this right?
B
14
S
1
Posts: 66
Reputation: 771

Post » Sat Nov 28, 2015 9:19 pm

try this one Test.capx
Last edited by korbaach on Sat Nov 28, 2015 9:32 pm, edited 1 time in total.
Image
B
65
S
23
G
7
Posts: 1,505
Reputation: 10,896

Post » Sat Nov 28, 2015 9:22 pm

korbaach wrote:@LittleStain try this one Test.capx


Thank you!! this worked fine!!!
B
14
S
1
Posts: 66
Reputation: 771

Post » Sat Nov 28, 2015 9:27 pm

mikelantzelo wrote: this worked fine!!!


this NOT worked fine!!!

on start you have 100 sprites..after you loop 99 times.. how much sprites left?

I think it should remain only one..
Last edited by korbaach on Sat Nov 28, 2015 9:27 pm, edited 1 time in total.
Image
B
65
S
23
G
7
Posts: 1,505
Reputation: 10,896

Post » Sat Nov 28, 2015 9:27 pm

mikelantzelo wrote:
Paulo Cezarino wrote:You used the wrong condition. It's pick random instance.



What do you mean? I want to remove 20 random instances. Code says that remove instance 0 every time.. isn't this right?


It's almost right. Construct 2 does not update the instance's number until the end of the loop. So, inside the loop, after instance 0 is destroyed, there will be no instance 0 until the next event.

Edit: My bad! korbaach already addressed the issue. Turns out I was having the same bug on my game but I never counted the instances too... thanks, man! :­)
Last edited by Paulo Cezarino on Sat Nov 28, 2015 9:48 pm, edited 1 time in total.
Winstratos on:

Twitter
Facebook
Tumblr
B
12
S
5
G
1
Posts: 23
Reputation: 1,602

Post » Sat Nov 28, 2015 9:29 pm

that will never work fine...
.because c2 destroys sprites on the next tick..so loop can choose one sprite several times...
you need a boolean instance variable.."destroyMe" :D

Image
Image
B
65
S
23
G
7
Posts: 1,505
Reputation: 10,896

Post » Sat Nov 28, 2015 9:31 pm

Your message contains too few characters.
Last edited by korbaach on Sat Nov 28, 2015 9:33 pm, edited 2 times in total.
Image
B
65
S
23
G
7
Posts: 1,505
Reputation: 10,896

Post » Sat Nov 28, 2015 9:31 pm

mikelantzelo wrote:you are right.. can you post a corrected .capx file?

test2.capx
Last edited by korbaach on Sat Nov 28, 2015 9:44 pm, edited 3 times in total.
Image
B
65
S
23
G
7
Posts: 1,505
Reputation: 10,896

PreviousNext

Return to How do I....?

Who is online

Users browsing this forum: David181, OBLIVION, senecaa and 19 guests