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
gdevelop5:events:functions [2019/06/13 21:30]
piyushpalawat99
gdevelop5:events:functions [2019/07/02 22:03] (current)
4ian
Line 77: Line 77:
  
 This is a really simple and not really useful example of a function (you could as well use the action to rotate objects directly without writing a function). But, when you add more complex logic inside, a function'​s strength can be seen. It's then super easy to reuse this logic from the rest of the game! This is a really simple and not really useful example of a function (you could as well use the action to rotate objects directly without writing a function). But, when you add more complex logic inside, a function'​s strength can be seen. It's then super easy to reuse this logic from the rest of the game!
 +
 +<​note>​If your function is a condition or an expression, [[gdevelop5:​events:​functions:​return|use the actions in "​Functions"​ category to set the expression/​condition value]] (also called the "​return value"​). </​note>​
  
 ## Using the function in your game ## Using the function in your game
Line 87: Line 89:
  
 That's it! The function is used like any other condition, action or expression in the [[gdevelop5:​interface:​events-editor|Events Editor]]. That's it! The function is used like any other condition, action or expression in the [[gdevelop5:​interface:​events-editor|Events Editor]].
 +
 +<note tip>
 +The **Object Groups** feature, while creating functions, helps grouping similar object parameters. This way you can apply an action/​condition to a group of object parameters (parameters pointing at objects) at once.</​note>​
  
 ## Advanced usages ## Advanced usages
  
 This page gave a basic overview of what functions are. They are one of the more powerful features of GDevelop, as you can extend the events by using them, enabling to create very readable and concise events sheets. By using them, you can reduce the amounts of events that you write for your game, avoid copy-pasting them and even reduce bugs by ensuring that functions are always used for common tasks on your objects. This page gave a basic overview of what functions are. They are one of the more powerful features of GDevelop, as you can extend the events by using them, enabling to create very readable and concise events sheets. By using them, you can reduce the amounts of events that you write for your game, avoid copy-pasting them and even reduce bugs by ensuring that functions are always used for common tasks on your objects.
 +
  
 ### Recursive functions ### Recursive functions
Line 97: Line 103:
  
 <note important>​Be very careful when writing a recursive function. If you don't add conditions, the function could call itself infinitely, blocking your game.</​note>​ <note important>​Be very careful when writing a recursive function. If you don't add conditions, the function could call itself infinitely, blocking your game.</​note>​
 +
 +You can [[gdevelop5:​events:​functions:​return|use the actions in "​Functions"​ category to return expression/​condition values]]. ​
  
 ### Sharing functions ### Sharing functions