我看到了 libgdx MathUtils.randomBoolean(chances),我想这对我有帮助,但我不确定。
MathUtils.randomBoolean(10); // I'm not sure if this will give 10% chance?
Run Code Online (Sandbox Code Playgroud)
MathUtils.randomBoolean(float chance)给出true参数给出的概率。但是参数chance可以取值之间0 - 1,这意味着例如0.1给出10%( 0.1) 返回的概率true。
你的例子 - 10- 总是会导致true它大于1.
| 归档时间: |
|
| 查看次数: |
853 次 |
| 最近记录: |