【问题标题】:What is wrong with the restart game function in corona电晕中的重启游戏功能有什么问题
【发布时间】:2014-03-05 21:07:09
【问题描述】:

重启游戏功能似乎不起作用,我不知道为什么。气球,分数重置,但游戏没有重置,我不能再次射击气球。 (加上 askUser、yesBtn 和 noBtn 也不会隐身)

function createBalloons(a, b)
  for i = 1, a do
     for j = 1, b do

         local balloon = display.newImage ('balloon_fat_red.png', 270+ (i * 30), 80 + (j * 50))
         balloonText = display.newText(hiragana_array[x+1], 300, 125)
         balloonTextt = display.newText(hiragana_array[x+2], 300, 175)
         balloonTexttt = display.newText(hiragana_array[x+3], 300, 225)
         balloonText:setFillColor( 1,1, 0 )
         balloonTextt:setFillColor( 1,1, 0 )
         balloonTexttt:setFillColor( 1,1, 0 )
         balloon.name = 'balloon'
         physics.addBody(balloon)
         balloon.bodyType = 'static'
         table.insert(balloons, balloon)
         end
    end
    target.text = #balloons
end
    function restartLvl()  
        for i = 1, #balloons do
        display.remove(balloons[i])
        print ("restart level")
        end

        score.text = '0'
        ballRemain.text = '3'
        balloons = {}
        createBalloons(1, 3)
        askUser.isVisible = false
        yesBtn.isVisible = false
        noBtn.isVisible = false
        print("time from start: ", (system.getTimer()-gameTime))
        print('send mail')
        sendMail()

    end

这是它在模拟器中显示的内容。

【问题讨论】:

  • 你能显示 createBalloons() 吗?另外,您的意思是它在您的标准输出的最后一行之后没有响应,但在此之前它在打印第三个重启级别后响应良好?
  • askUser、uesBtn 和 noBtn.isVisible 由于某种原因无法正常工作
  • 也许你在游戏结束时暂停了物理和/或移除了 ontouch-handler,并且没有在 restartLvl 中启动物理?

标签: lua coronasdk


【解决方案1】:

我没有看到该代码有任何问题,我猜问题出在其他地方。您将不得不再挖掘一点,也许再放一些打印语句。例如,isVisible 可能在 restartLvl 之后被另一个函数重置为 true,就像在 enterFrame 处理程序中一样。

【讨论】:

    猜你喜欢
    • 2013-08-19
    • 2023-04-11
    • 1970-01-01
    • 2013-08-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多