How do I use loops/for each

Get help using Construct 2

Post » Sun May 22, 2016 6:33 pm

hi guys, I have a small problem... I have a enemy that has pinned a body part. That part has a turret behavior that has as target the body. As soon I make copies of my enemy, the bodyparts of all enemies aquire the first as target. But I need that they go to aquire their own body. I tried several stuff...but no result...can U help me ?
People told me with LOOPS -for each.... but I don t get it :(

can U show me how to use it on 3 objects ? Body + limb1 that has target body + limb 2 that has target limb 1 ?

thanks :) ...U would save me from ignorance :)
B
37
S
16
G
2
Posts: 447
Reputation: 4,865

Post » Sun May 22, 2016 6:45 pm

Hey,
could you provide a simple example of your mechanic? I'm not sure i get what you want :)

Anyway sounds like you could make use of containers:
https://www.scirra.com/manual/150/containers
B
22
S
7
G
4
Posts: 154
Reputation: 3,709

Post » Sun May 22, 2016 8:31 pm

here it is...a s soon i copy the snake: mess ! I need eeeexatly that stuff that I made...but with many snakes
https://l.facebook.com/l.php?u=https%3A ... =YAQGYDnVm

thanks
B
37
S
16
G
2
Posts: 447
Reputation: 4,865

Post » Mon May 23, 2016 5:31 pm

If there is one chick in the room, and someone says: give the chick a kiss. You give the chick a kiss.

If there are 50 chicks in the room, you got to choose wich chick. Or (in your case) ask someone to point to the right chick.

As @5Type suggested, use containers.

https://drive.google.com/open?id=0B1SSu ... zhoenJqbkU

What are containers ?
Look: https://www.google.be/search?q=scirra+c ... containers
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Mon May 23, 2016 6:04 pm

thanks a lot, very kind !!!!!!!!!!!!!
B
37
S
16
G
2
Posts: 447
Reputation: 4,865

Post » Mon May 23, 2016 6:21 pm

Ysvw, do you understand the difference? Because if you understand this, you understand a big whole lot of c2.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Mon May 23, 2016 7:17 pm

ehm... so and so,...but i am happy 4 any help
I was hoping a file where my stuff there is identicall... but maybe with some little code for loop... is that not possible ???
B
37
S
16
G
2
Posts: 447
Reputation: 4,865

Post » Mon May 23, 2016 10:05 pm

@mariogamer the example capx that @99Instances2Go gave you is exactly that.
Your code but with containers and loops integrated.

1. He made the "Player" a container for all the Blob-elements (find that in the sidebar menu)
2. He destoyed the initial objects on start, since they are only there for configuration purposes (Event #1 - #2)
3. He added an Event "On Player created" which picks the player instance that is created (Event #5)
4. He setup the sub elements accordingly in position and behaviors (pin, turret) (Event #6)
5. He added 6 players to the layout to showcase the functionality (Event #3)

Now everytime a "Player" object is created all neccessary work is done the way you want it to.
B
22
S
7
G
4
Posts: 154
Reputation: 3,709

Post » Tue May 24, 2016 11:14 am

thanks a lot 4 ur help !!!!!!!!!!!!!!!!!!!!!!!!!
B
37
S
16
G
2
Posts: 447
Reputation: 4,865


Return to How do I....?

Who is online

Users browsing this forum: Bobbyneal100, mikehive, newt, tinhofiel and 43 guests