I'm merely toying with the idea, so I apologize if it seems I haven't given too much thought to it.
Basically, I know that you normally include your header created by krencoder when you build your project. The header simply seems to hold values corresponding to the sprites in the .dat file.
But what if I want to make a game that allows you to create your own dat files? Would you need to rebuild your entire app with the new header? Obviously I could script it to load in the .dat, but the header can't be included in an already-built project. There isn't anything else to the header file so I imagine you could probably just load in the values specified and use them in your own code. You'd probably load them in a map or vector or something.
Or is there some already-provided-for way that I didn't see?
Yep - every message that takes an ID:
void SetAction (U32 id)
also has a string form:
void SetAction (const std::string &actionName)
So it can be:
sprite->SetAction( RUN );
sprite->SetAction( "RUN" );
I actually prefer the string form, myself. And it allows for the kind of dynamic naming you are talking about.
Although that is an unusual approach - usually you want to keep the names the same and just change the assets. In this case, that means fixing the names and created new .dat files with the same object names, although there is nothing wrong with using dynamic names loaded from another source.
I hope that I've understood your issue... basically you want the users to be able to load their own dat-files on an existing program, right?
I've done similar thing (skin for my program). In that case, I can't compile my project with a static dat-file. I have to make sure that the program is able to read and PROCESS external information ( from dat-file). An issue has been addressed sometime ago:
At the end, I 'hide' additional information in the tags for the sprites. The modified source codes is available at:
Unfortunately, there's no proper documentation. I'm thinking to blog the idea for what I've changed. But there' still not enough time :-(
Phuoc Can HUA
Finally, I've got a chance to minimize my existing project to a demo program:
In my case, I'm allowing users to define their skin with XML-files and create their own dat-file.
I use "empty" sprites to embed information in the dat-file (as suggested in https://sourceforge.net/forum/message.php?msg_id=2670718\), e.g.
I also use them to define the position of a group of buttons (sprites):
<Frame deltax="0" deltay="0" />
The action name is used to define a group name. The button belongs to this group is defined as:
<Frame x="15" y="20" width="220" height="90" hotspotx="0" hotspoty="0" />
If you change deltax/y above you can move all buttons with:
I hope that I'll be able to write a proper document for that one day. But basically, I want to show is that I use "empty" sprite to encode additional information. Also, more information is encoded in the Action name (seperated by '|')
Phuoc Can HUA
Phuoc Can HUA --
Great to see the project go up! Congratulations!
I'm not sure this is directly applicable to what you want to do, but you can embed binary and text data in the .dat files.
Thanks a lot.
Indeed, I did consider external text file. But then the user defined information has to be splited in different files (https://sourceforge.net/forum/message.php?msg_id=2670794)
There's also a technical issue. I have to parse the external file. Also, if the information is defined in the XML-file error can be already found in encoding phase.
Of course, the perfect solution would be to enhance the encoder to convert new tags. Since I didn't understand the encoding part of Kyra I decided to go with the quick & dirty solution, i.e. using dummy sprite to carry additional information, not very efficient :-)
Log in to post a comment.