Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Rodrigo Braz Monteiro edited this pageApr 1, 2018 ·1 revision

Overview

Components are what allowEntities to be different from one another. They store the data associated with each entity, and grant them properties by making them visible to families (seeSystems).

Components should normally be fine grained. For example, if you want a moving sprite on the screen, consider having three components representing that: aPositionComponent, aVelocityComponent, and aSpriteComponent.

Declaring Components

Syntax

Components are code generated (seeECS Overview). They follow the following format:

component:name:TextLabelmembers:    -text:'Halley::TextRenderer'    -layer:int    -mask:int

At top level, the YAML document should contain an entry calledcomponent. It should have two keys inside it,name, specifying a unique name for the component (NB: the actual class generated will haveComponent appended to it, so in the example above it would generate a class calledTextLabelComponent), andmembers, which is a list containing all members in the component.

Each member is specified by a name, followed by its C++ type. Note that it's necessary to use the full namespace for Halley classes, as the components will be compiled in translation units that don't invokeusing namespace Halley;

At this time, it's not possible to specify default values, and all component members must be explicitly initialised in the generated constructor.

Custom types

If any of your members uses a type that your game declares, you need to help the codegen find the appropriate header to include. You can do this by using a declaration in this format:

type:name:CurveTypeinclude:"src/config/art/curve_type.h"

Note that the name must match exactly. e.g. if your component needs astd::vector<CurveType>, you'd need to declare a type forname: 'std::vector<CurveType>'.

f

Clone this wiki locally

[8]ページ先頭

©2009-2025 Movatter.jp