如何让事件每 8 帧和最后两帧发生(处理)?

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

我每 8 帧发生一次事件,使用:

if (frameCount % 8 ==1){}

我不能使用:

if (frameCount % 8 < 1){}

因为它会触发两帧的事件,但我需要事件在模数等于 1 时开始。

基本上我希望在模数等于 1 和 2 时触发事件,但我不知道该怎么做。我可以在其中指定一个范围吗?

谢谢!

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

不,一个操作不能同时有 2 个结果。如果 frameCount 可被 1 整除 2.

,则您想触发该事件

您必须使用 ||-运算符 (logical OR):

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