Your browser (Internet Explorer 6) is out of date. It has known security flaws and may not display all features of this and other websites. Learn how to update your browser.
X

Solkraft Tutorial 3: Setting Up Your Own Properties and Attributes

In this tutorial we will describe how to add your own properties and attributes to your project.

Let’s begin by going to the SolKraftEngine\projects\yourprojectname\resourcefiles\ directory. In here, create a new directory called “blueprints”, like this:

SolKraftEngine\projects\yourprojectname\resourcefiles\blueprints

We don’t have to mess with CMakeLists files this time, because this isn’t in the \code\ directory, which is convenient. In this new folder, create a new file called PropertyAndAttributeDefinitions.xml and open it. In here we want to define every new property that we want to create, and all attributes attached to that property. Start by adding a tag called <Properties> </Properties> and then within these, define our new property:

<Properties>

<Property name=”PropertyName”>
<var name=”AttributeName1″ type=”int” value=”5″/>
<var name=”AttributeName2″ type=”string” value=”thisisastring”/>
</Property>

</Properties>

The “value” value here is the default value of that attribute, if you don’t manually set the attribute to something, this is the value it will have. “type” is the data type of the attribute, the supported data types for attributes are: int, float, string, char, bool, and glm::vec2.

After this you should go to your \code\ directory and (if you want) create a new folder for your soon-to-be-created properties (don’t forget to modify CMakeLists.txt accordingly if you do!). In here, create two new c++ code files: propertyname.cpp and propertyname.h. As for the header file, you have to make sure to inherit the class from the PropertyBase base class and to run the SetUpProperty() macro in the class, like this:

#include “BaseClasses\PropertyBase.h”

class PropertyName: public PropertyBase
{

SetUpProperty(PropertyName);

public:
PropertyName();
~PropertyName();

};

And in the .cpp file, all you have to do is run the ImplementProperty() macro just below the includes:

#include “PropertyName.h”
#include “FactoryManager.h”

ImplementProperty(PropertyName);

PropertyName::PropertyName()
{
}

PropertyName::~PropertyName()
{
}

That’s all there is to adding a new property with attributes!

Leave a comment  

name*

email*

website

Submit comment