Reputation: 176
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
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