我想将这些发射器对象添加到组中而无需手动执行。我打算做Emitter ..我但它不是一个字符串
local function createEmitter(X,Y)
local emitter = display.newEmitter( emitterParams )
emitter:scale(1.5,1.3)
emitter.isVisible = false
emitter.x =X
emitter.y =Y
return emitter
end
emitter_1 = createEmitter()
emitter_2 = createEmitter()
emitter_3 = createEmitter()
for i=1,3 do
EmitGroup:insert(emitter_1)
end
答案 0 :(得分:0)
不是使用for循环将其添加到组中,而是可以将它们插入到函数本身中。
local function createEmitter(X,Y)
local emitter = display.newEmitter( emitterParams )
emitter:scale(1.5,1.3)
emitter.isVisible = false
emitter.x =X
emitter.y =Y
EmitGroup:insert(emitter) -- Added line
return emitter
end
emitter_1 = createEmitter()
emitter_2 = createEmitter()
emitter_3 = createEmitter()
- 对于i = 1,3做 - EmitGroup:insert(emitter_1) --end