2014-05-03 140 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

謝謝它有助於更​​清晰的和/或更簡單的方式! –