您好我想在3张照片中随机选择'BCloud1.png,BCloud2.png,BCloud3.png'
什么是最好的方法,我尝试添加math.random(1, 3);
,如: star4.imgpath = "BCloud .. math.random(1, 3); .. .png";
但那不起作用
-- select randomly between BCloud1.png, BCloud2.png, BCloud3.png
local star4 = {}
star4.imgpath = "BCloud1.png";
star4.movementSpeed = 16000;
table.insert(starTable, star4);
对此问题的任何简单修复?
答案 0 :(得分:4)
您的语句有一点语法错误。它应该是:
star4.imgpath = "BCloud"..tostring(math.random(1, 3))..".png";