Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Last revision Both sides next revision
gdevelop5:events:foreach [2018/07/20 15:49]
4ian
gdevelop5:events:foreach [2019/05/19 14:09]
piyushpalawat99
Line 1: Line 1:
 # For Each events # For Each events
  
-A For Each event is a kind of [[gdevelop5:​events|event]] that will take an object as parameter. Then, during the game, for every instance of the object, the conditions and actions will be repeated.+A For Each event is a kind of an [[gdevelop5:​events|event]] that will take an object as parameter. Then, during the game, for every instance of the object, the conditions and actions will be repeated.
  
-Usually, you don't need For Each event as conditions ​and then actions will automatically run on all the objects ​(refined ​by the conditions). However, from time to time, For Each event can be useful to run an action that is depending ​on each instance of the object.+Usually, you don't need to use "For Each" events. Conditions ​and actions will automatically run on all of the objects. They are defined ​by their conditions. However, from time to time, "For Each" events ​can be useful to run an action that depends ​on each instance of the object.
  
 ## Examples ​ ## Examples ​
Line 9: Line 9:
 <note tip>​**See it in action!** 🎮\\ <note tip>​**See it in action!** 🎮\\
 Open these examples online.</​note>​ Open these examples online.</​note>​
 +
 +[[https://​editor.gdevelop-app.com/?​project=example://​shooting-bullets-explanation|{{:​gdevelop5:​events:​shootingbulletsexplanationexample.png?​200|}}]]
  
 * https://​editor.gdevelop-app.com/?​project=example://​shooting-bullets-explanation * https://​editor.gdevelop-app.com/?​project=example://​shooting-bullets-explanation
 +
 +[[https://​editor.gdevelop-app.com/?​project=example://​platformer|{{:​gdevelop5:​behaviors:​platformerbehavior.png?​200|}}]]
 +
 * https://​editor.gdevelop-app.com/?​project=example://​platformer * https://​editor.gdevelop-app.com/?​project=example://​platformer
  
 ## When to use it ## When to use it
  
-Consider ​this example. When the player is in collision with an object called "​KillAllEnemyBonus",​ we set the "​life"​ variable of all enemies to 0. We also want to create a special kind of explosion at the position of each enemy. We need a For Each event, ​otherwise ​a single explosion would be created ​the position of the first enemy:+Consider ​the example ​below. When the player is in collision with an object called "​KillAllEnemyBonus",​ we set the "​life"​ variable of all enemies to 0. We also want to create a special kind of explosion at the position of each enemy. We need a "For Each" ​event to accomplish this. Otherwise, a single explosion would be created ​at the position of only the first enemy:
  
 {{ :​gdevelop5:​events:​for-each-example.png?​nolink |}} {{ :​gdevelop5:​events:​for-each-example.png?​nolink |}}
-