이 코드입니다 : 게임은 떨어지는 공을 생성내 센서를 corona sdk에서 제대로 작동하게 만드는 방법은 무엇입니까?
local bottombar = display.newLine(0, 480, 340, 480)
physics.addBody(bottombar, "static", {isSensor = true})
function bottombar:collision(event)
if(event.phase == "began") then
a = a + 1
print(a)
if(a == 4) then
timer.cancel(timer1)
storyboard.gotoScene("scene_results")
end
end
end
bottombar:addEventListener("collision", bottombar)
end
와 나는 3 공 바닥 line.Variable 'A는 처음에 0, 첫 번째 공을 패스를 통해 통과 할 때 게임을 중지하려면 콘솔의 라인 A는 1 번째 공은 라인을 통해 전달 될 때 콘솔 A는 2이고 저를 도시이다 통해 이런 다음 라인 3 :
1 => first ball
2 }
}=> second ball
3 }
I가 if(a == 10)
을하면 첫 번째 공 'a'는 1, 두 번째 공 'a'는 (2, 3), 세 번째 'a'는 (4, 5, 6)이며 네 번째 공이 'a'선을 통과하면 (7 , 8, 9, 10).
또는 (내가 그들을 터치하면 self:removeSelf()
) 내가 3 개 공을 파괴하고 난 4 볼이 라인을 통해 통과 할 경우 'A'가 될 : 난 문법 실수가있는 경우
1
2
3
4
가 미안 해요.
이 전체 코드가, 내가 잘못 뭘하는지 알아낼 수있다 :
local a = 0
local score = 0
local function game()
local pop = audio.loadSound("pop.WAV")
local masterVolume = audio.getVolume()
local function createCircle()
function onCircleTouch(self, event)
if(event.phase == "began") then
timer.performWithDelay(1, function()
self:removeSelf()
audio.play(pop,{channel=0,loops=0})
score=score+10
globals.score = score
end)
end
return true
end
local circle = display.newImage("ballon2.png",math.random(10,300),0)
physics.addBody(circle, "dynamic", { desity=1.0,friction=0 })
circle.touch = onCircleTouch
circle:addEventListener("touch", circle)
end
local function balls(event)
createCircle()
local bottombar=display.newLine(0, 480, 340, 480)
physics.addBody(bottombar, "static" ,{isSensor=true})
function bottombar:collision(event)
if(event.phase == "began") then
a=a+1
print (a, event.other)
if(a == 3) then
timer.cancel(timer1)
storyboard.gotoScene("scene_results")
end
end
end
bottombar:addEventListener("collision", bottombar)
end
timer1=timer.performWithDelay(1000, balls, 0)
end
game()
어떻게 신고합니까? 지역 a = 0? –
@TeddyEngel 예 –
@Schollii이 코드는 무한한 공을 생성합니다 (timer1 = timer.performWithDelay (1000, balls, 0)) –