Using Novelty > Property binding

Property binding

Property binding enables you to directly bind the property of an object (size, color, etc) with a game variable. When the variable is changed, either by a script or an action, the bound object will be notified automatically.


Display game variables in text

The simplest kind of property binding is where you bind the value of a game variable to a text object.

To inject the value of a game variable into text, simply type [$variable] anywhere in the text. Replace variable with the name of the variable you wish to bind to. This is a very easy way to make a score counter, for instance:


Fig 1: The yellow text indicates a property binding.


Advanced property binding

To bind the property of an object with a game variable you will need to do some more work. For starters, objects need to explicitly expose their properties before anyone can bind to them. This is done with NoveltyML, when the object is created. An example would be if you created a clock object and wanted to expose the two hands' rotation-properties for property binding.

The NoveltyML for creating an object binding looks like this:

<Image name="My image" texture="My texture">
	<Binding name="My binding" attribute="size.width"/>
</Image>

This creates a binding called "My binding" and it hooks into the width-property of the object. Binding a game variable to it can then be done in the Novelty editor. The new binding will appear in the Property inspector under Property bindings. This is where you should enter the name of the variable you wish to bind to.


Fig 2: Binding the property to a game variable

In this case, as the score value rises so will the object's width, essentially turning it into a progress bar.


Valid binding attributes

Value Description
position.left Horizontal position
position.top Vertical position
rotation Rotation
scale Scale
size.width Width
size.height Height
color.red Red color
color.green Green color
color.blue Blue color
color.opacity Opacity



Back to top