It seems I really don't expect SKAction for a range

Sorry if this sounds too primitive. It seems I really don't understand how SKAction works for a range. I have seen several posts, but I am not clearly explaining (as far as I understand) how to calculate my range. For example, I saw the ranges below:

SKAction.wait(forDuration: 2.5, withRange: 3.0),  //Wait between 1.0 and 4.0 seconds
SKAction.wait(forDuration: 0.65, withRange: 0.7),//Wait between 0.3 and 1.0 seconds

I am not sure how to reconcile the above to calculate the wait time from 1.0 to 2.0 seconds and from 0.2 to 0.8 seconds.

+4
source share
1 answer

Time forDurationis the average action time. time withRangegives tolerance on both sides of the time forDuration.

withRange 2 / forDuration.

SKAction.wait(forDuration: 2.5, withRange: 3.0),  //Wait between 1.0 and 4.0 seconds
//3.0 / 2 = 1.5; 2.5 - 1.5 = 1.0; 2.5 + 1.5 = 4.0

SKAction.wait(forDuration: 0.65, withRange: 0.7),//Wait between 0.3 and 1.0 seconds
//0.7 / 2 = 0.35; 0.65 - 0.35 = 0.3; 0.65 + .035 = 1.0

, 1.0 2.0 ,

SKAction.wait(forDuration: 1.5, withRange: 1.0)

0,2 0,8

SKAction.wait(forDuration: 0.5, withRange: 0.6)

forDuration Range:

forDuration = t_min + (t_max - t_min) / 2
withRange = (t_max - t_min)
+4

Source: https://habr.com/ru/post/1665760/


All Articles