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:objects [2019/09/19 21:12]
4ian
gdevelop5:objects [2020/12/03 09:16] (current)
4ian [Angle]
Line 1: Line 1:
 # Objects # Objects
  
-GDevelop ​games are based on objects that are displayed ​on the sceneThey can be animatedmoved and manipulated in different ways. Different kind of objects are available and provide specific features:+In GDevelop, everything ​on the screen is an _object_This includes — but is not limited to — the playable character, enemies, and parts of the environment.
  
-[[gdevelop5:​objects:​base_object|Features for all objects]] +You can create different types of objects for different purposes. For example, ​[[gdevelop5:​objects:​sprite|Sprite]] ​objects ​add animated graphics to a game, while [[gdevelop5:​objects:​text|Text]] objects add text to a game. 
-[[gdevelop5:​objects:​sprite|Sprite ​objects]] + 
-[[gdevelop5:​objects:​tiled_sprite|Tiled Sprite ​objects]] +You can also use [[gdevelop5:​behaviors|behaviors]] to add functionality to objects ​and create [[gdevelop5:events|events]] that affect an object'​s attributes (position, size, etc). 
-[[gdevelop5:​objects:​particles_emitter|Particle emitters]] + 
-[[gdevelop5:​objects:​text|Text objects]] +## List of objects 
-[[gdevelop5:​objects:​panel_sprite|Panel Sprite ​("9 patch"​) ​objects]] + 
-[[gdevelop5:​objects:​text_entry|Text entry objects]] +This section lists the different types of objects, each of which serves a unique purpose. 
-[[gdevelop5:​objects:​shape_painter|Shape Painter objects]] + 
-[[gdevelop5:​objects:​video|Video ​objects]] (experimental) +- [[gdevelop5:​objects:​bbtext|BBText]] 
-[[gdevelop5:​objects:​skeleton|Skeleton ​(skeletal animated ​object)]] (experimental)+[[gdevelop5:​objects:​panel_sprite|Panel Sprite ​("​9-path"​)]] 
 +[[gdevelop5:​objects:​particles_emitter|Particles emitter]] 
 +[[gdevelop5:​objects:​shape_painter|Shape painter]] 
 +- [[gdevelop5:​objects:​skeleton|Skeleton]] 
 +[[gdevelop5:​objects:​sprite|Sprite]] 
 +- [[gdevelop5:​objects:text|Text]] 
 +[[gdevelop5:​objects:​text_entry|Text entry]] 
 +[[gdevelop5:​objects:​tiled_sprite|Tiled Sprite]] 
 + 
 +Refer to the linked pages to learn more about each type of object. 
 + 
 +### Experimental objects 
 + 
 +This section lists _experimental_ objects. They'​re under development and are more likely to change than the non-experimental objects. 
 + 
 +[[gdevelop5:​objects:​video|Video]] 
 + 
 +## Creating an object 
 + 
 +1. Open the [[gdevelop5:​interface:​scene-editor|Scene editor]]. This is the default view after creating a new project. 
 +2. In the **Objects** panel, select **Click to add an object**. 
 +3. In the **Add a new object** dialog, select a type of object. 
 +4. Configure the object. The available settings depend on the type of object. 
 +5. Select **Apply**. 
 + 
 +{{ :gdevelop5:​objects:​base_object:​pasted:​20200406-092728.png?​nolink ​|}} 
 + 
 +## Adding an instance of an object to a scene 
 + 
 +After creating an object, GDevelop doesn'​t immediately add it to a scene. You need to add the object to the scene via the **Objects** panel. You can add as many copies of the object to the scene as you like. 
 + 
 +{{ :​gdevelop5:​objects:​coin-selected.png?​nolink&​200 |}} 
 + 
 +Each copy of an object in a scene is referred to as an _instance_ of the object. All instances of an object share the same underlying behavior as the original object, but you can customize them independently of one another. For example, each instance of an object may have a different position in the scene. 
 + 
 +## Modifying an instance of an object 
 + 
 +If you select one or more instances of an object, the **Properties** panel appears on the left side of the screen. This panel displays information about the selected instance(s). 
 + 
 +{{ :​gdevelop5:​objects:​object-propeties-button.png?​nolink&​200 |}}  
 + 
 +You can customize the following properties of an object'​s instance: 
 + 
 +### Position 
 + 
 +All objects have coordinates. These coordinates correspond to the horizontal position (X-axisand the vertical position (Y-axis) on the [Cartesian plane](https://​en.wikipedia.org/​wiki/​Cartesian_coordinate_system). The X-coordinate decreases as you go to the left and increases as you go to the right. The Y-coordinate increases as you go down and decreases as you go up. 
 + 
 +{{ :​gdevelop5:​objects:​base_object:​pasted:​20200406-092924.png?​nolink }} 
 + 
 +### Angle 
 + 
 +The **Angle** option defines the rotation of an object in degrees. The following illustration demonstrates how GDevelop understands the angle of rotation: 
 + 
 +{{ :​gdevelop5:​objects:​gdevelop_co.png?​nolink&​400 |}} 
 + 
 +<note important>​If you use trigonometric functions like the sine or the cosine, you need to express the angles in radians. (1 radian = 180/PI degrees and 1 degree = PI/180 radians. PI is the number which is approximately equal to 3.14159). You can use expressions `ToRad` and `ToDeg` in events to convert between degrees and radians.</​note>​ 
 + 
 +### Z Order 
 + 
 +When objects on the same layer overlap, the **Z Order** of the object determines whether the objects appear in front or behind one another. For example, an object with a **Z Order** of `2` appears in front of an object with a **Z Order** of `1`. 
 + 
 +In the following image, the Z order of the bush on left is `2`, the Z order of the coin is `1`, and the Z order of the bush on the right is `0`: 
 + 
 +{{ :​gdevelop5:​objects:​coin-bush-zorder.png?​nolink&​400 |}} 
 + 
 +The value of the **Z Order** field can be any integer, including negative numbers and zero. 
 + 
 +### Layer 
 + 
 +All objects exist on a layer. Objects are then drawn onto the screen layer-by-layer,​ from bottom to top. This means an object on the top layer will always appear in front of objects on the bottom layer (even if the objects in the bottom layer have a higher **Z Order** value). 
 + 
 +{{ :​gdevelop5:​objects:​base_object:​pasted:​20200406-093010.png?​nolink |}} 
 + 
 +Typically, background objects, interactive objects (such as the playable character), and UI objects exist on different layers, but there are no strict requirements. 
 + 
 +### Lock position/​angle in the editor 
 + 
 +Sometimes, a scene has a lot of objects and it's difficult to select a specific instance. If you enable the **Lock position/​angle in the editor** option, you can no longer select the instance, which makes it easier to select the instance you _do_ want to select. 
 + 
 +{{ :​gdevelop5:​objects:​base_object:​pasted:​20200406-093052.png?​nolink |}} 
 + 
 +### Instance variables 
 + 
 +An instance variable is a [[gdevelop5:​variables|variable]] that's specific to an instance of an object. The **Instance variables** table lets you define the variables attached to the instance and the values of those variables. 
 + 
 +{{ :​gdevelop5:​objects:​base_object:​pasted:​20200406-092023.png?​nolink |}} 
 + 
 +For more information,​ refer to [[gdevelop5:​variables:​object-variables|Object variables]]. 
 + 
 +### Custom size 
 + 
 +If enabled, you can change the height and width of the object instance. This height and width is distinct from the dimensions of the original object. 
 + 
 +{{ :​gdevelop5:​objects:​base_object:​pasted:​20200406-093137.png?​nolink |}} 
 + 
 +## Organizing objects into groups 
 + 
 +You can organize objects into _groups_ and then refer to all of the objects in that group by a single name. 
 + 
 +This makes it possible to create events that applies to lots of objects without repeating events multiple times, increasing performance of your game, maintainability,​ and readability of your events. 
 + 
 +To organize objects into groups: 
 + 
 +1. In the toolbar, select the **Groups** icon. 
 +2. Select **Click to add a group**. 
 +3. Select the group. 
 +4. In the **Edit group** dialog, select the objects to add the group. 
 +5. Select **Apply**. 
 + 
 +{{ :​gdevelop5:​objects:​base_object:​pasted:​20200406-093739.png?​nolink |}} 
 + 
 +<​note>​By default, the name of a group is "​Group"​. To rename a group, right-click the group and select **Rename**.</​note>​
  
-There also exists features that work without objects, for example AdMob that allows you to display ads on your Android or iOS device. You can read more about AdMob [[gdevelop5:​all-features:​admob|here]].  ​ 
-Read more about [[gdevelop5:​all-features|all other features here]].