Gluon/es
Introducción
Esta sección te ofrece la documentación necesaria para las diversas funciones de Gluon:
Gluon: Lo básico
Los juegos creados con GluonEngine se construyen de la misma manera. En este capítulo se describe brevemente cómo funciona. Si todavía no entendes cómo trabajan los sistemas basados en el modelo GameObject/Componet, este el sitio apropiado para comenzar.
Iniciando con Creator
Una vez que entiendas el diseño básico de un juego construido con GluonEngine, estarás listo para echar un vistazo a GluonCreator, la herramienta con la que construirás los juegos. En este capítulo se describe la interfaz de usuario y los flujos de trabajo de la herramienta.
Creando Juegos
Una vez que hayas leído los dos primeros capítulos y te encuentres dispuesto a comenzar la construcción de juegos con Gluon, adelante hazlo!. En algún punto puedes quedar atascado y tal vez necesitas más ayuda con ciertos detalles, aquí es donde querrás buscar.
Gluon: Lo básico
Los juegos creados utilizando el motor de juegos Gluon, GluonEngine, se llaman GameProjects. Se componen de una variedad de diferentes tipos de objetos, que trabajan juntos para crear un juego. La siguiente es una breve introducción a cómo funciona la estructura de un GameProject. Podes empezar a trabajar con GluonCreator sin saber esto, pero te hará la vida más fácil si entendés estos términos básicos, ya que se utilizan en todo el resto de la documentación.
=La jerarquía GameObject
En la parte superior de la jerarquía Gluon GameObject esta el GameProject, que es básicamente el juego entero. Un GameProject contiene una o más Escenas, que pueden ser cualquier cosa, desde un mapa de nivel o una pantalla del menú. Una escena se compone de uno o más GameObjects. Un GameObject es un árbol de GameObjects o cualquier número de componentes. Un GameObject representa una unidad funcional en una escena, como un objeto Auto, que también puede estar compuesto por otras partes que son GameObjects en sí mismos (como una mochila, un cohete o un arma). Los Componentes proporcionan la lógica que opera en el GameObject al que se adjuntan. Los componentes pueden ser conectados a cualquier número de propiedades. Las propiedades representan simplemente un monton de datos almacenados en el disco, como un archivo de sonido o una imagen.
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.
More on Components
Components are like properties that you can attach to GameObjects, such as a "render" Component that actually makes the GameObject visible, or a "SoundListener" Component that gives the object the ability to listen to sounds. Components can also be scripts that controls the behaviour of the GameObjects attached to them. All GameObjects in Gluon have their Transform properties built-in, giving the object its position, rotation, and scale (it doesn't make much sense to have an object that doesn't have at least a position). Components do not have Transform properties, but the GameObject to which a Component is attached to does.
Introducing Creator
In the image to the right you can see Gluon Creator in its default layout, with the Invaders sample loaded. In a rough clock-wise order, the elements of the window are:
Project
- This shows all the Assets that you have in your project, such as sounds, textures, scripts and Scenes.
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.