local mRandom = math.random
local objects = {"rocket02" ,"rocket01","coin01"}
local objectTag = 0
local object = {}
local function spawnObject()
objectTag = objectTag + 1
local objIdx = mRandom(#objects)
local objName = objects[objIdx]
object[objectTag] = display.newImage("image/object_"..objName..".png")
*object[objectTag].x = 30+mRandom(320)
object[objectTag].y = 200
object[objectTag].name = objectTag*
print(objectTag)
end
timer.performWithDelay(1,spawnObject,3)
答案 0 :(得分:0)
您可以使用此代码块查看图像加载是否存在问题
local mRandom = math.random
local objects = {"rocket02" ,"rocket01","coin01"}
local objectTag = 0
local object = {}
local function spawnObject()
objectTag = objectTag + 1
local objIdx = mRandom(#objects)
local objName = objects[objIdx]
object[objectTag] = display.newImage("image/object_"..objName..".png")
if object[objectTag] ~= nil then
print( "Image succesfully loaded." )
else
print( "Image couldn't be found." )
end
*object[objectTag].x = 30+mRandom(320)
object[objectTag].y = 200
object[objectTag].name = objectTag*
print(objectTag)
end
timer.performWithDelay(1,spawnObject,3)