Hi Guys.
I hit a problem a few days ago which I couldn't find an answer to.
It just didn't make sense.
I think I've finally nailed it, but the problem still doesn't make sense, and seems to be down to object error rather than Krush error.
I can't upload the cap, but I can try and explain the method of coding used, and why the error (to me) doesn't seem right.
I use groups extensively, because they can be used in so many ways, and are a great way to control your code.
I generally have one or two groups active at a time to control the game, with occasional groups being enabled to perform a function or set up as a handler, which self-terminate when needed.
Now, with this in mind, lets say I have a MainLoop group which monitors keyboard input, enables other groups that update the screen, etc.
When a specific key is pressed (lets say Space), the group will terminate itself and enable another main control group (lets say MainLoop2).
Now, from this MainLoop2 group, all sorts of things could happen, and control could be passed around to various other groups, and some groups enabled to perform a specific self-terminating task.
It's not important really, because it's just an example, but it gives an idea of how I structure my coding with Construct.
It works very well.
That is until a few days ago.
I noticed that the MainLoop group which monitors keyboard input for certain tasks was still triggering even when the group was disabled.
Obviously, this meant things went haywire, and it took me a little while to notice that the disabled group had an event that was still triggering.
Even more bizarrely, when I created a Global Variable "Phase" to make sure that the event couldn't trigger more than once (by setting it to 1 and adding a condition to the event allowing it to only trigger when it was 0), it still triggered, even though the debugger shows that the variable Phase was 1, and therefore it should be impossible for the event to trigger.
What's all this got to do with the Wait Object?
Well, this afternoon, I spent a considerable amount of time going through the code (and wondering if I should have written it in HGE and C++ after all), I noticed that to set the timing of automated events, I'd used the Wait Object.
I haven't used this object in any other projects, and only added it in the last couple of weeks because someone mentioned it on these boards.
I hadn't even realised it was there until then.
I am now in the process of replacing all the Wait commands with my own wait loops, but it looks like things are now triggering only when they should.
I can't explain why using the Wait Object would make things act so strangely.
I think that there were only about 5 or 6 Wait commands used, but it knocked my game for six.
I'm not sure how easy it would be to reproduce the error in a sample cap, because I'm just glad to be able to get on with my game, rather than binning it.
But if you are using the Wait Object and you are getting strange behaviour for no apparent reason, it's something worth looking at.
Once I've replaced them all with my own wait loops, I'll post back here and see if it solved all the problems.
In the meantime, anyone else have strange behaviour with the Wait Object?
Krush.