Looping through newly created objects

Get help using Construct 2

Post » Thu Jan 23, 2014 9:48 am

Hello

When I create multiple objects of the same type and try to loop through them afterwards it only finds one object that existed on the begining.
Here is a .cpax example of this situation: https://tinyurl.com/nghm57z.
After creating 10 objects and looping through them I get count = 1.
I can add that I don't have this problem when I create objects in one layout and go to another. It counts all objects.

Can someone tell me if this is a bug or it should be done differently?KRegiel2014-01-23 09:49:58
B
3
Posts: 6
Reputation: 187

Post » Thu Jan 23, 2014 10:45 am

I made it work using "repeat 10 times" instead of "for"

And got the "foreach" loop out of the "start of layout" , trigged by keyboard key instead.

This way, I got the expected results
B
8
S
4
Posts: 131
Reputation: 1,205

Post » Thu Jan 23, 2014 2:08 pm

There is a count expression you can use as well, if all you want to do is count how many of a certain object is on the layout.

Create your sprites
Set text to sprite.count

B
101
S
32
G
11
Posts: 1,552
Reputation: 21,667

Post » Fri Jan 24, 2014 7:06 am

Sprite.count works in this situation but there still is a problem with selecting by value, so I think I have to move it to another event like c13303 suggested.

Thanks for help
B
3
Posts: 6
Reputation: 187


Return to How do I....?

Who is online

Users browsing this forum: Yahoo [Bot], yiuyiu6666 and 20 guests