Instanced loops

For questions about using Classic.

Post » Mon Jul 20, 2009 4:06 pm

I'm creating a loop based platform engine, and I want more players to be on the screen at the same time.

I want to use the same sprite for the different players, and only change a variable to make each player control his sprite.

This looks like the best solution to have a low amount of events.

However, the loop isn't obviously instanced for each player, so when the loop stops for a sprite, it stops for every sprite.

How can I solve this?
B
2
S
2
G
5
Posts: 512
Reputation: 2,674

Post » Mon Jul 20, 2009 4:16 pm

[quote="SuperV":2jdtry09]for each player[/quote:2jdtry09]

You've pretty much answered your own question there. Make two loops:

[code:2jdtry09]
+ For each player
+ While Player is overlapping ground
-> Push Player out
[/code:2jdtry09]

Just be careful with nesting loops, because they can turn into CPU eaters pretty quick.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Mon Jul 20, 2009 7:59 pm

dependin on how many players you will use it might be better to just use a cloned sprite and repeat the events.
B
2
S
2
G
4
Posts: 259
Reputation: 1,968

Post » Mon Jul 20, 2009 8:20 pm

In fact you can put a loop below any condition at all that picks from 'player', and the actions will only run on the instance(s) that met the parent event. This is how subevents work - they inherit the picking from the parent.

Edit: manontherun: that actually wouldn't be a good idea, it would be much more work! It's easily possible with deadeye's method.
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,468

Post » Mon Jul 20, 2009 8:25 pm

depending on players quote, because nested loop is suggested. but i dont disagree with you.
B
2
S
2
G
4
Posts: 259
Reputation: 1,968


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 7 guests