Enyak Stew
Enyak Stew

Reputation: 176

How to make event happen every 8 frames and last two frames (processing)?

I have an event happening every 8 frames, using :

if (frameCount % 8 ==1){}

I cannot use :

if (frameCount % 8 < 1){}

because it would trigger the event for two frames, but I need the event to start when the modulo is equal to 1.

Basically I would like the event to be triggered when the modulo is equal to 1 AND 2, but I don't know how to do that. Can I specify a range in there ?

Thanks !

Upvotes: 1

Views: 148

Answers (1)

Rabbid76
Rabbid76

Reputation: 211166

I would like the event to be triggered when the modulo is equal to 1 AND 2

No, an operation cannot have 2 results at once. You want to trigger the event, if frameCount is divisible by 1 or 2.

You have to use the ||-operator (logical OR):

if (frameCount % 8 == 1 || frameCount % 8 == 2) {
    // [...]
}

Upvotes: 0

Related Questions