我是 Lua 新手,正计划开发 Bingo 游戏。我创建了 25 个网格,并且随机生成了数字。但是网格中的数字重复我已经搜索过但我找不到帮助我的朋友。
--enter code here
local widget = require "widget"
local storyboard = require( "storyboard" )
local scene = storyboard.newScene()
local xaxis = {40,80,120,160,200,40,80,120,160,200,40,80,120,160,200,40,80,120,160,200,40,80,120,160,200}
local yaxis = {40,40,40,40,40,80,80,80,80,80,120,120,120,120,120,160,160,160,160,160,200,200,200,200,200}
local img = {}
local i
local k
local u={}
for i = 1, 25 do
img[i] = display.newImageRect( "t.png", 39, 39 )
img[i].x=xaxis[i]
img[i].y=yaxis[i]
math.randomseed( os.time() )
j = math.random(1,75)
u[i], u[j] = u[j], u[i]
img[i] = display.newText(j,0,0,native.systemFont,20)
img[i].x=xaxis[i]
img[i].y=yaxis[i]
end
数字是随机生成的,但数字是重复的