when a loop is done?

Get help using Construct 2

Post » Tue Jan 27, 2015 1:08 pm

hi,
when a loop is done? i create a random map by using the steps below. now i want to replace 2,3 created sprites AFTER the loop - e.g with pick random sprite1 instance

-on start of layout
--system: for "x"from to to int(sprite2.width / 16) - 1
---system: for "y" to int(sprite2.height / 16) - 1 System create Object "fam1" on layer 0 at 0,0
fam1: set position to ((Sprite2.X - Sprite2.Width / 2) + (loopindex("x") * 16+ 7) , (Sprite2.y - Sprite2.Height / 2) + (loopindex("y") * 16 + 7)



thanks
B
5
Posts: 42
Reputation: 313

Post » Tue Jan 27, 2015 1:15 pm

Add a sub event (under start of layout, not under the loop) and use the system action: Pick random instance?
B
19
S
6
G
7
Posts: 1,101
Reputation: 6,146

Post » Tue Jan 27, 2015 1:46 pm

already tried that... nothing happened
see screenshot attached.

thanks
You do not have the required permissions to view the files attached to this post.
B
5
Posts: 42
Reputation: 313

Post » Tue Jan 27, 2015 2:47 pm

move all the sub events over 1 and make 1 under

Image
B
6
S
1
Posts: 51
Reputation: 502

Post » Tue Jan 27, 2015 2:47 pm

tried some other conditions - all are working fine except the pick instance.

any idea?

thanks
B
5
Posts: 42
Reputation: 313

Post » Tue Jan 27, 2015 2:53 pm

@trultz
same result.... i think the problem is "pick a random instance"

thanks
You do not have the required permissions to view the files attached to this post.
B
5
Posts: 42
Reputation: 313

Post » Tue Jan 27, 2015 3:03 pm

found a workaround... at least for me it looks like a workaround....

i've to add a action "wait 1 seconds" and then run the "pick a random instance" then it works good...

cant understand why i need to wait 1 second..... do i need to increase the 1 second if the double for loop takes longer????

thanks
B
5
Posts: 42
Reputation: 313

Post » Tue Jan 27, 2015 3:05 pm

I think this might have to do with the way C2 strangely picks "Created" objects right away, but "Spawned" ones a tick later. Can you try replacing the Spawn action with System - Create object - earth1.x earth1.y and see if you can do without the wait? Also, you can try a Wait of 0.01 seconds or whatever, I think that might work.
B
19
S
6
G
7
Posts: 1,101
Reputation: 6,146

Post » Tue Jan 27, 2015 3:13 pm

@somebody
thanks for your help. system - create object without a wait action does not work, however waiting for 0.01 seconds works perfect!

strange, but now it works.

thanks
B
5
Posts: 42
Reputation: 313

Post » Tue Jan 27, 2015 8:07 pm

You might prefer a "wait 0", it will execute the remaining actions at the end of the event sheet, with no wait.
B
75
S
31
G
27
Posts: 1,000
Reputation: 20,735

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 8 guests