Sprite SKAction repeatActionForever set random wait time

Thank you for your help. The sequence is SKActionas follows:

SKAction *seq = [SKAction sequence:@[wait, throwAnim, run]];
SKAction *req = [SKAction repeatActionForever:seq];

Is there a way to make the wait a random duration, or can it be controlled during repetition forever?

+3
source share
1 answer

You can use waitForDuration: withRange:

The duration parameter represents the average wait time, and the range represents the deviation.

Each time an action is performed, the action calculates a new random value for the duration. Duration can vary in any direction up to half the value of the durationRange parameter.

, 5.0 2.0, 4.0 6.0

+10

All Articles