spread values?

For questions about using Classic.

Post » Fri Mar 21, 2008 6:51 pm

I'm using duplicates of the same object and want to access each object in a fastloop, in mmf i'd use the spread value method to identify each duplicate, how do you do it in construct?

I've noticed in the properties they are listed as having unique id's, how to you retrieve them through events?

Thanks.
B
37
S
19
G
18
Posts: 613
Reputation: 10,231

Post » Fri Mar 21, 2008 6:58 pm

There is a function "Name.UID" which gives Universal ID, not everything can use this for ex. Gradient object
B
4
S
2
G
4
Posts: 719
Reputation: 2,938

Post » Fri Mar 21, 2008 7:05 pm

Spread values are kind of obselete in Construct because you only would use them to fastloop through each instance of an object, and 'For Each' in the system object does this much more easily. If you make the condition 'For Each Sprite', the conditions beneath it and the event actions and subevents are repeated once for each instance of Sprite, each time with just the current Sprite instance picked.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,580

Post » Fri Mar 21, 2008 8:49 pm

I see now. The 'for each' sounds very nice.

I've tried it but when i try to run the app i get this error

"Temp.exe has encountered a problem and needs to close. We are sorry for the inconvenience."


I add a box to the frame,
I create the condition "always" then action fastloop "fall" no.of boxs amount of loops.

Then next event condition, on loop "fall", + condition "for each box", then the action set box.y to box.y +1

Then i get that error.
B
37
S
19
G
18
Posts: 613
Reputation: 10,231

Post » Fri Mar 21, 2008 8:53 pm

i can confirm it's the "for each" condition causing the error, when i remove it the app runs fine.
B
37
S
19
G
18
Posts: 613
Reputation: 10,231

Post » Fri Mar 21, 2008 8:57 pm

okay i had them in the same condition box, when i put the "for each" condition into a "sub-event" instead it works fine.

Can i ask what the difference is?
B
37
S
19
G
18
Posts: 613
Reputation: 10,231

Post » Fri Mar 21, 2008 9:05 pm

Hey use Edit option ok? Double post is bad, Triple Post is very bad!
And sub event just mean that the main condition is fulfilled and its own. Its like Loop in a Loop with condition XD.

Edit:

Here's example:

If A is rectangle then Add +1 to score
and if A is square then Add +1 to score

So if you have square the score will be 2, if a different rectangle it will be 1, if neither it will be 0.
B
4
S
2
G
4
Posts: 719
Reputation: 2,938

Post » Sat Mar 22, 2008 10:17 pm

It shouldn't have crashed, can you set it up so it crashes and send the .cap to ashley@scirra.com?
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,580

Post » Sun Mar 23, 2008 9:52 am

You can download the cap. file here,

[url:1di1a4kr]http://www.mediafire.com/?k1plldp7hnm[/url:1di1a4kr]
B
37
S
19
G
18
Posts: 613
Reputation: 10,231

Post » Sun Mar 23, 2008 4:09 pm

You've misunderstood how to put together a for-each loop - you don't need the other loop at all, for-each works on its own! In the .cap you provided, all you need to do is:

+ For Each Box
: (actions)

and that does all the repeating and picking for you automatically, it's really very simple. Still, it shouldn't crash no matter what combination of conditions you come up with, so I'll try fixing that for next build.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,580

Next

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 4 guests