|
*** quite a usefull function (though one can do without it)
One can use this function to associate your own data structure to an object.
Whether one decides to use this function or not depends on one's programming style.
The obvious alternative for using this function is to have your own structure or class
for each object and that one of the fields in your class would be the object_handle through which
you can access the STATE functions.
Parameters:
object_handle:
a handle to an object
my_own_data:
A pointer to a class or structure or even a function. This pointer can point
to whatever you want it to point. The Engine doesnt do anything with this pointer
it simply save it for you so you can call STATE_object_get_my_own_data() to retrieve it.
This parameter can also be NULL.
Example:
typedef struct object_data
{
int health;
int power;
int number_of_times_that_got_hit;
double height;
int weapon_type;
And anyother data you might need in your program
} object_data;
object_data obj_data; or use new(), malloc() or whatever ...
STATE_object_attach_my_own_data(my_object, &obj_data);
Example B:
there is no function for detach so just call like this
STATE_object_attach_my_own_data(my_object, NULL);
Note that the attached data is not saved when calling STATE_engine_save()
so you need to save it yourself (or see the See also section).
See also STATE_object_set_object_type_number(), STATE_object_set_control_type_number
|