User Tools

Site Tools


components

Differences

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

Link to this comparison view

Both sides previous revision Previous revision
components [2019/12/18 18:05]
maxime created
components [2020/01/23 13:36] (current)
maxime
Line 2: Line 2:
 Components are small modules used to define the behavior of any game object. Game objects can have any number of components, but can have only one of each type. Components are small modules used to define the behavior of any game object. Game objects can have any number of components, but can have only one of each type.
  
-See the list of all available components ​[[api#​Component Classes|here]].+See the [[api:#Component Classes|list of all available components]]. 
 + 
 +---- 
 + 
 +You can define new types of components with the ''​mod:​registerClass''​ function. 
 + 
 +When you define a new component type, you can assign it properties that are editable, usable in your component'​s behavior, and that can be saved in a savegame. Those properties must have a name and a type. They can also have a default value, flags, and access functions (getter and setter). 
 + 
 +Components can also have functions. In addition to new functions, you can override some base functions that are automatically called for all components:​ 
 +  * ''​**create**()'':​ when the component is created 
 +  * ''​**init**()'':​ when the component is initialized in the game 
 +  * ''​**update**()'':​ at each frame 
 +  * ''​**onEnabled**()'':​ when the component is enabled 
 +  * ''​**onDisabled**()'':​ when the component is disabled 
 +  * ''​**onFinalize**(//​_isClearingLevel//​)'':​ when the component is destroyed, only if it has been initialized  
 +  * ''​**onDestroy**(//​_isClearingLevel//​)'':​ when the component is destroyed, after ''​onFinalize''​ 
 +   
 +You can see an example of component definition in the mod Example 02 in ''​scripts/​component/​COMP_ANTENNA.lua''​ 
 + 
 +----
  
 Components can be added to any FBX node with the ''​mod:​registerPrefabComponent''​ function. Components can be added to any FBX node with the ''​mod:​registerPrefabComponent''​ function.
components.txt · Last modified: 2020/01/23 13:36 by maxime