It looks like you're new here. If you want to get involved, click one of these buttons!
void orxFASTCALL Game::UpdateScore(){
orxOBJECT *object = Tools::GetObjectByName("Skore"); // get score object
orxConfig_Load("Skore.ini");
orxConfig_GetKey(0);
orxConfig_PushSection("SkoreString");
orxConfig_SetS32("String", pocetKrtku); // update String in config file with actual score
if (object != orxNULL) {
orxObject_Delete(object); //delete text object
orxObject_CreateFromConfig("Skore"); //and create it again so it will update
}
}
Comments
Give this a try:
Be aware, I am making assumptions about what your code is here. Firstly, SkoreString in your Skore.ini file is a text object.
Like this:
and secondly, I am assuming that your variable 'pocetKrtku' is a pre-prepaired string of text to replace everything else with.
and variable pocetKrtku is simple int with actual score
*first edit* okay my original suggestion was bad, sorry. I'll have a fix in a second when I correct my horrid assumptions
*edit two goes here!
(and sorry for taking so long!)
try also setting your
[SkoreText] object to [SkoreString] afterwards. (This should 'update' the text object with the now-formatted string object.)
*edit:* " orxObject_SetTextString( [SkoreText], [SkoreString] ) " might be of use to you. I believe this will allow you to do both steps. Update the [SkoreString] (for formatting etc) and then update the [SkoreText]with the [SkoreString].
I wanted to give more details about some of the functions you were calling in your first version though:
You might not want to call orxConfig_Load() in an update function as it will read the original data from disk and it is likely to kill your performances.
This function has no effect if you don't store it's result. It's only use is to access config entries when you don't know their actual key (if you want to parse all the key/value pairs in a section for example). Shouldn't you store your object again here? Otherwise your reference will still point to the deleted one, which could produce flickering artefacts.
Also you don't call orxConfig_PopSection() which will lead to undefind behavior.
Who call this update function? Is it called from the core clock or from another one, possibly one you created? If so, when turning VSync to off, they can't be synchronized and that will also result in flickering artefacts.
Hope this helps!
This crashes on strcpy. I also tried many other ways and always get compile error or crash on strcpy or SetTextString. Not mention that this code looks horrible for me
And also sorry for taking time with my response, have some things to do.
And for last, thank you for explaining me how orxConfig functions work, I've learned something new again
Your strcpy crashes because you didn't allocated any memory for the destination string. If you want to duplicate a string you need to call strdup (or orxString_Duplicate).
In your case you should be able to use the C string directly with something like:
If it doesn't compile you might simply have to add a cast on the second parameter.
Now closer to my display glitch problem. I'm using one spawner for enemies in game, standard clock for time updating (every second) and display problem appears when all spawned objects are deleted and new appears.
You talked about clock syncing. I found function for resync clock or all clocks but nothing changed.
And for more info. I'm using 4 text objects with own font, all of them configured in config files and if I comment font definition (text is rendered with basic font) in one of them, problem dissapears.
If you want to keep that private, you can send me a link via the private messaging feature of the forum.
In your case to keep everything synchronized on the same clock (the core one that also does the rendering) I would instead use orxClock_AddGlobalTimer() to update your time left counter instead of creating a new clock.
I got your message, I'll try this tonight and let you know what I find.
I'll try again on a MacBook but I don't have access to it right now. Maybe could you upload a video of the glitch as I'm not exactly sure what to look for?
Also, I found an optimization bug in vs2008's compiler with your project in release, leading to a stack corruption!
If I slightly change a line while not changing its logic, the bug disappear. Very scary! ^^
Anyway, here is video witch text render glitch.
Edit: wasn't successful uploading it here, so there's link
http://www.ipappdb.com/Glitch.mov
You can fix it by changing your input function to directly return the result from orxRender_GetWorldPosition() (using return *orxRender_GetWorldPosition(...);).
EDIT: I'll look at the video at home tonight.
What version of orx are you using? Which version of MacOSX/drivers?
Have this glitch even on iPhone (teser and device) and Windows too - Windows XP prof. Visual Studio 2008 pro
You'll also get a bunch of new features, improvements and better performances. You can read the full list in the CHANGELOG file.
I'll try SVN sources tonight, hope I won't have any problems :P