Hi,
I'm working on a project with SFML and am having a problem.
As the title suggests, I need to spawn a sprite every x milliseconds, where x is at least 100ms but variable (set at compile time) up to about 500ms. I'm using an if-else block, as I will sometimes (usually) need to delete an old sprite when a new one is created. My problem is that occasionally, the sprite won't be created. Some debug messaging confirms that the if branch has not been taken. I should note that by occasionally, I have determined about 1 missing sprite in every 500 or so. There is no obvious pattern to when one is missing.
My initial thought is that the problem is to do with the OS process scheduling and that the process might not always be running at the right time to trigger the branch. Performing an action at regular intervals can't be an uncommon problem though, so is there a better way of doing this?
I should mention that this if-else block is running in a separate thread, which loops over the block (for the moment) from the end of the initialisation routine in main() until the program exits.
I'd be grateful for any advice.