Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
gdevelop5:objects:base_object [2020/04/06 09:42] 4ian [In the events editor] |
gdevelop5:objects:base_object [2020/12/26 13:56] (current) |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | # Common features to all objects | + | < |
- | + | ||
- | In a GDevelop game, everything on the screen is an object. | + | |
- | + | ||
- | ## Add an object to the game | + | |
- | + | ||
- | In a scene, we can add objects by simply clicking the add object button on the right, on the bottom of the objects list: | + | |
- | {{ : | + | |
- | + | ||
- | You can choose from many different type of objects, all with specific properties and purpose: | + | |
- | + | ||
- | {{ : | + | |
- | + | ||
- | Depending on what type of object you have chosen, the editor, aspect of the object and the available features in the events will be different. As the goal of this page is to explain objects in general, we won't go in to details of these unique properties on each type. You can find [[http:// | + | |
- | + | ||
- | # Objects in the scene | + | |
- | + | ||
- | ## Add an instance on the scene | + | |
- | + | ||
- | An object can be positioned on the scene by selecting the object in the Object tab (click/tap on it) and then drag them into the scene to put an *instance* of that object. An *instance* is basically a copy of the object living on the scene. Each instance has its own variables, position, animations (for sprite objects), content (for texts), etc... | + | |
- | + | ||
- | On the scene editor, you can: | + | |
- | * change the position of an object by selecting the object in the scene editor and drag it. | + | |
- | * scale the object by selecting the object and dragging one of the white handles: | + | |
- | * rotate the object by selecting the object and dragging the rounded white handle: | + | |
- | {{ : | + | |
- | + | ||
- | ## Modifying Instance properties | + | |
- | + | ||
- | When you select an instance in the scene editor, the properties panel on the left shows information about the selected instance(s). If it is not open, you can re-open it by clicking the properties button in the toolbar: | + | |
- | {{ : | + | |
- | + | ||
- | ### Position | + | |
- | + | ||
- | You can precisely set the position of the selected instances by changing the X and Y values in the properties: | + | |
- | + | ||
- | {{ : | + | |
- | + | ||
- | ## Angle | + | |
- | + | ||
- | You can set the angle of the instance(s) by changing the angle value: | + | |
- | {{ : | + | |
- | + | ||
- | The angle can be any value from 0 to 360 degrees. Remember this diagram to see what is the orientation of a given angle: | + | |
- | {{ : | + | |
- | + | ||
- | ## Z order | + | |
- | + | ||
- | You can change the Z order of an instance in the properties: | + | |
- | {{ : | + | |
- | + | ||
- | The purpose of the Z order is to allow to specify which object will be displayed first, when instances are overlapping. More precisely, you can control if the object is behind or in front of another object: when two objects are overlapping, | + | |
- | + | ||
- | Values can be any integer, including negative numbers and 0. | + | |
- | + | ||
- | {{ : | + | |
- | On the above 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. | + | |
- | + | ||
- | ## Layer | + | |
- | + | ||
- | You can set the layer of an instance: | + | |
- | + | ||
- | {{ : | + | |
- | + | ||
- | A layer acts as a *virtual container* for objects displayed on the screen. Objects are drawn on a layer, which is by default the **“base layer”**, and the layer is then drawn on the screen. A scene can have multiple layers. For example, there can be a layer to display controls on screen, another to display a menu, another for a map, and yet another for a background. | + | |
- | + | ||
- | ## Lock position/ | + | |
- | + | ||
- | By ticking the box "Lock position/ | + | |
- | + | ||
- | {{ : | + | |
- | + | ||
- | When the instance is locked, we can not longer select it in the scene. There are times when you have lot of object instances overlapping each other in your scene. This makes it difficult to select some of them as you keep selecting the ones you don't intend to. In such cases, you can lock the instances. | + | |
- | + | ||
- | You can unlock a locked instance by opening the instances panel, which is displaying all the instances in our scene and select the object from the list. | + | |
- | + | ||
- | ## Instance variables | + | |
- | + | ||
- | The " | + | |
- | + | ||
- | {{ : | + | |
- | + | ||
- | A variable is basically a container that is holding a value (a number, a text), which can be compared and modified during the game. There are different type of variables in GDevelop. In particular each object can *define* variables. When the game is running, each *instance* of the object living on the scene will have its own variables. | + | |
- | + | ||
- | < | + | |
- | + | ||
- | The table allows you to specify variables that are specific to the selected instance. For example, if you have objects representing boxes with gold on the scene, you can modify the variable named " | + | |
- | + | ||
- | ## Custom size | + | |
- | + | ||
- | You can change the size of your objects, by enabling the custom size in the properties panel, and then enter the custom *width* and *height* dimensions in pixels: | + | |
- | + | ||
- | + | ||
- | {{ : | + | |
- | + | ||
- | # Object groups | + | |
- | + | ||
- | An object group is a set of objects. For example, a group called " | + | |
- | + | ||
- | This makes 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 open the Groups Editor, click the groups icon on the toolbar: | + | |
- | {{ : | + | |
- | + | ||
- | In the Groups Editor are listed all the groups of the scene (and global groups too, which are available in all scenes of the game). To add a group click on the button on the bottom of the list: | + | |
- | {{ : | + | |
- | + | ||
- | A new group is added to the list: | + | |
- | {{ : | + | |
- | + | ||
- | * To change the name of the group, right click on the group and select | + | |
- | * To add objects to the group, tap or click the group. | + | |
- | + | ||
- | In the window that open to edit the group, click on the bottom field and choose an object (or type the name of an object) to add it to the group. | + | |
- | + | ||
- | {{ : | + | |
- | + | ||
- | # Variables | + | |
- | + | ||
- | Each object can contain variables, which are memory cells that you can use to store information. When the game is running, each *instance* of the object living on the scene will have its own variables. | + | |
- | + | ||
- | Read [[gdevelop5: | + | |
- | + | ||
- | # Timers | + | |
- | + | ||
- | Objects can hold their own timers, and each timer will be unique | + | |
- | + | ||
- | For example, a classic usage is to simulate shooting bullets. If you have a single tank on the scene, you could use a scene timer so that every 3 seconds, this tank can fire (create a bullet) and then reset the timer (so the tank can shoot again). | + | |
- | + | ||
- | The issue is that if you have 2 tanks and use a scene timer you'll notice both tanks shoot at the same time, because they are sharing the same scene timer. | + | |
- | You need to have two separate timers, independent from each other, to make the second tank to shoot at its own rate. But what if you have 100 tanks? You don't want to create 100 scene timers, one per instance. | + | |
- | + | ||
- | This is when object timers are getting useful: replace every condition/ | + | |
- | + | ||
- | You can read more about timers here: [[gdevelop5: | + | |
- | + | ||
- | # Visibility | + | |
- | + | ||
- | By default, object instances are all marked as visible, meaning that they are displayed on the screen. Using events, you can **hide** any instance during the game. An hidden object instance won't be displayed anymore, but will still live on the scene (reacting to collisions, and following all other events as usual). | + | |
- | + | ||
- | <note tip>Some objects, like Sprite or Text objects, can also have an **opacity**. The opacity, between 0 and 255, defines how transparent an object is (0 being fully transparent, | + | |
- | + | ||
- | # In the events editor | + | |
- | + | ||
- | You can change and manipulate the properties of an instance of an object, or of multiple instances, using events during the game. This is even what game making is all about in GDevelop: to manipulate objects in real-time as we play the game. As the events and events editor are out of the scope of this page, refer to [[gdevelop5: | + | |
- | + | ||
- | * All objects share the **same common features** (like position, angle and everything that is written on this page), and there are a lot of conditions and actions that you can use for all objects. You can [[gdevelop5: | + | |
- | * Objects can also provides you with specific feature. For example, [[gdevelop5: | + |