PropertyCollection
Introduction
PropertyCollections are a method of encapsulating a group of property values. Using PropertyCollections can simplify and make code more readable.
Using PropertyCollections
The following example creates a Sprite and sets its properties through a PropertyCollection.
Lack of Type Conversion in PropertyCollections
Unlike assigning properties using regular code the values assigned to properties through PropertyCollections must match the type exactly. For example the following code is acceptable:
The value of 3 is an integer value, as opposed to 3.0f, but the compiler casts the value to a float without any problem. However, the following code would result in a crash:
Instead, XVelocity must be explicitly given a float:
Did this article leave any questions unanswered? Post any question in our forums for a rapid response.
Last updated