2014-05-03 86 views
1
shape:setY(math.random(0, 450 - 50)) 

的Math.random功能是什么,我理解,但究竟是什么在mat.random功能使用算术运算符的意思,上面LOC说,在为什么它是450 - 50而不是400?有什么不同?的Math.random功能定位对象与最小值和最大值

同样,

self:setPosition(540, math.random(160) + 40) 

回答

3

没有区别。它相当于shape:setY(math.random(0, 400))

的第二行代码等同于以下内容:

self:setPosition(540, math.random(1, 160) + 40) 

它肯定意在写

self:setPosition(540, math.random(41, 200)) 
+0

谢谢它有助于更​​清晰的和/或更简单的方式! –