tompawarrior
07-17-2007, 05:30 PM
Hello, I'm trying to create a custom resource which contains some attributes and a sprite. What i can't find out is how to load this resource:
<resources>
<tile name="grass" terrain="100" cover="100">
<sprite name="grass">
<image file="grass.png">
</image>
</sprite>
</tile>
</resources>
I know how to load the attributes but can't find a way to load the sprite part:
CL_ResourceData_Tile *data = (CL_ResourceData_Tile *) resource.get_data("tile");
terrain = data->get_object().terrain;
cover = data->get_object().cover;
sprite = ???;
I tried some different approaches like this:
<resources>
<sprite name="grass" terrain="100" cover="100">
<image file="grass.png">
</image>
</sprite>
</resources>
It actually works if i use this code:
sprite = new CL_Sprite(resource_id,manager);
but it will probably break if i want to add more elements to it later.
Just want to hear if theres a better way of solving this or something.
<resources>
<tile name="grass" terrain="100" cover="100">
<sprite name="grass">
<image file="grass.png">
</image>
</sprite>
</tile>
</resources>
I know how to load the attributes but can't find a way to load the sprite part:
CL_ResourceData_Tile *data = (CL_ResourceData_Tile *) resource.get_data("tile");
terrain = data->get_object().terrain;
cover = data->get_object().cover;
sprite = ???;
I tried some different approaches like this:
<resources>
<sprite name="grass" terrain="100" cover="100">
<image file="grass.png">
</image>
</sprite>
</resources>
It actually works if i use this code:
sprite = new CL_Sprite(resource_id,manager);
but it will probably break if i want to add more elements to it later.
Just want to hear if theres a better way of solving this or something.