Gluon/da
Intro
Dette afsnit giver dig dokumentation til de forskellige dele af Gluon:
Grundlæggende om Gluon
- Spil som laves ved brug af GluonEngine er alle lavet på samme måde. Dette kapitel beskriver kort, hvordan det virker. Hvis du ikke allerede forstår, hvordan systemer baseret på GameObject/Component-paradigmet virker, så er det stedet at starte.
Introduktion til Creator
- Når du forstår det grundlæggende design af et spil bygget med GluonEngine, er du klar til at se på Gluon Creator, det værktøj, som du bruger til at lave spil. Dette kapitel beskriver brugergrænsefladen og arbejdsgange med værktøjet.
At lave et spil
- Når du har læst de to første kapitler og føler sig klar til at begynde at lave et spil med Gluon, så gå bare i gang. Skulle du går i stå på et tidspunkt og have brug for yderligere hjælp med noget, så kan du finde det i dette afsnit.
Grundlæggende om Gluon
- Spil bygget ved hjælp af GluonEngine kaldes GameProjects. De består af en række forskellige typer af objekter, der arbejder sammen om at skabe et spil. Det følgende er en kort introduktion til, hvordan strukturen i et GameProject virker. Du kan begynde at arbejde med gluon Creator uden denne viden, men det vil gøre dit liv nemmere, hvis du forstår disse grundlæggende begreber, som de benyttes i resten af dokumentationen.
The GameObject Hierarchy
- At the top of the Gluon GameObject Hierarchy is the GameProject, which is basically your entire game. A GameProject contains one or more Scenes, which can be anything from a level map or a menu screen. A Scene is composed of one or more GameObjects. A GameObject is a tree of GameObjects or any number of Components. A GameObject represents a functional unit in a scene, like a Car object, which can also be made up of other parts which are GameObjects in themselves (like a rocket backpack or a weapon). Components provide the logic that operates on the GameObject they are attached to. Components can be attached to any number of Assets. Assets simply represent a piece of data stored on disk, like a sound file or an image file.
The GameObject hierachy is made up of instances of GluonEngine::GameObject in a tree structure with a parent-child system, each with any number of GluonEngine::Component instances. The Components provide most of the logic in the game, and since so many are usable in so many places, Gluon would ship with a number of pre-created Components (such as a Camera, Input handlers, MeshRenderer, TextureRenderer and so on).
The logic behind creating this system is to enable the game programmer to enforce encapsulation and create reusable components, which can then be applied to numerous GameObjects. It also allows for sane separation of the different types of logic required for each part of a GameObject, thus potentially creating cleaner, more readable code. At the same time, the structure described here would allow for the creation of a graphical tool to manage all of the components' settings. Components are implemented as plugins, making the code even more flexible and separated.
Mere om komponenter
Component'er er en slags egenskaber, som du kan knytte til GameObject'er, som fx en "render"-Component der gør GameObjekt'et synligt eller en "SoundListener"-Component, som giver objektet evnen til at høre lyde. Component'er kan også være scripter, som kontrollerer opførslen af de GameObject'er, som er knyttet til dem. Alle GameObject'er i Gluon har en indbygget Transform-egenskab, som giver objektet sin position, drejning og størrelse (der er ikke meget mening i at have et objekt, som ikke i det mindste har en position). Component'er har ikke Transform-egenskaber, men det har det GameObject som en Component er knyttet til.
Introduktion til Creator
På billedet til højre kan du se Gluon Creator i sin standard layout med eksemplet Invaders indlæst. I en rækkefølge nogenlunde med uret er vinduets elementer:
Project
- Dette viser alle Assets'ene i dit projekt, såsom lyde, teksturer, scripts og Scener.
Components
- This is a list of the pre-defined functionality available to you in Gluon Creator. The Components are things like sound emitters and listeners, camera controllers, input handlers and the like.
View
- This is the view of your current Scene from the perspective of the camera.
Scene
- The contents of the current Scene - in essence your scene graph.
Properties
- The place where you can see and manipulate every option on the various Components which are attached to the GameObjects in your game.
Messages
- This is where debugging messages, errors from scripts and other information from the various Components are shown.
Workflow in Gluon Creator
The work flow of using Gluon Creator to create games is based around the idea that you should be able to use your mouse for as much of the work as possible. As such, adding an Asset to your project is a task done by dragging a file into the Project pane from your file browser (or alternatively by clicking the "Add Asset..." button in the toolbar). It will then be copied to the project folder, and be made available for use in your game.
To describe a scene in a game, you select the appropriate Scene in the Project view, which causes it to be loaded and shown in the Scene pane, and in the View the camera view will show what the camera sees in the newly loaded scene. You can now edit this scene, by adding and removing GameObject to the Scene, and by adding Components to those GameObjects.
To add a GameObject to the scene, click on the "Add GameObject" button on the toolbar. This will add a new, empty GameObject to the Scene, and if you have an existing GameObject selected, the new one will be added as a child to the selected one. This allows you, as described in Gluon Basics, to build items for the game based on multiple GameObjects in a hierarchy, which all move along with each other.
So that you can change the values for the various Components, selecting a GameObject in the Scene view will make the properties for that object and all the Components on it show up in the Properties view, which is a scrollable, categorized list of all the various properties.
One of the functions which will be performed with some regularity from the Properties view is that of setting references to various Assets, for example setting the texture of a SpriteRenderer, or the sound of a SoundEmitter. This is done by clicking on the "..." button in the Properties view and selecting the appropriate item from the list.