Intervals

I’ve already found a work around for this problem, but I’m still wondering how this can be…

I start an Interval and the two if statements

if (Interval.isPlaying()):
    bla...
if (Interval.isStopped()):
    bla...

both return true at the same time(read: the interval hasn’t been stopped between the two statements). Although only isPlaying() should return true as the Interval was already started.

The workaround was to write

if (not Interval.isPlaying()):
    bla...

instead, to find out if an Interval is finished…

Before you ask, this code is part of my 3d Space Shooter. I’m starting LerpIntervals to handle gun fire.
You’ll find that code in the Showcase soon. :wink:

Sounds like this would match the code snipplets section? :slight_smile:

Regards, Bigfoot29

It’s a bit of a documentation bug, perhaps, and a bit of an unfortunate naming. But isPlaying() and isStopped() are not intended to be logical opposites.

isPlaying() returns true whenever the interval is in the active queue.

isStopped() returns true whenever the interval is in its initial or final state.

When you call interval.start(), you place the interval in the active queue, but its internal state doesn’t change until that queue gets processed. Thus, there is a brief window right after you call interval.start() in which both isPlaying() and isStopped() can return true.

Sometimes, you really want to know the answer to isPlaying(), and sometimes you really want isStopped(). So there is value to having the two different methods. I agree, however, that it would be less confusing if they had been given names that didn’t suggest they were supposed to be opposites.

David

Thanks David…

I’ve a task running to check the state of my intervals, so this task might have been executed, before the interval could really start…
Fortunately I’ve found this workaround quickly.