【问题标题】:Balloon game with Corona SDK带有 Corona SDK 的气球游戏
【发布时间】:2012-03-28 02:25:57
【问题描述】:

我对 iPhone/iPad 的游戏开发完全陌生。

我的代码已经运行,所有 10 个气球都漂浮在空中,但我有几个问题:

气球应按顺序或随机顺序。他们将肌腱移动到边缘,然后玩家应该用鼠标将气球移回正确的位置。怎么样?

什么是正确的维数(x,y),所以我的气球在屏幕上的显示和位置是一样的?

  1. 我的随机函数通过简单的点击不断弹出更多的气球。 我希望用户执行一些数学运算,例如添加两个随机气球并在屏幕上显示正确答案,以便结果可以移回气球放置的右边缘。如何编码?如何使用 2 个不同级别的难度? (L1, L2)

  2. 如何让我的气球移动到屏幕的不同边缘?

  3. 用户如何用鼠标将气球移回正确的位置?

  4. 如何将气球系在绳子上(水平)?以便用户做出选择。

  5. 我的背景图片大约是原来的 3MB (1024 x 768) 以与 iPad 分辨率很好地匹配,我可以在不影响 iPad 显示的情况下更改大小吗?

  6. 感觉局部气球1、2、3重复太多了,moveBalloon和applyLinear也是如此。有没有办法缩短它们?还是因为有10个气球是正常的?

  7. 我已经通过简单的点击为第一个气球添加了声音,是否应该为其余的 9 个气球复制相同的功能(又一团糟)?我会对所有人使用相同的声音。

非常感谢您的反馈。

【问题讨论】:

  • 我看到您尝试添加代码但不能。您是否尝试过选择代码并按下“{}”按钮?

标签: ios lua coronasdk


【解决方案1】:

如果您想要多个气球,使用一张桌子会容易得多。您可以毫不费力地拥有任意数量的气球。

 Balloons = {} -- track all baloons
 Function addBalloon(x,y,xVel,yVel)
     Tab = {x = x, y = y, vel = {x = xVel, y = yVel}}
     Table.insert(balloons,tab)
 End
 Function moveAllBalloons()
     For_,i in pairs(balloons) do
         i.x = i.x + i.vel.x
         i.y = i.y + i.vel.y      
     End
 End
  Function isPlaying
   For _,i in pairs(balloons)
     If --[[mouse.x]] <= i.x - (balloon.width/2) and --[[other parameters here]] then
         PlaySound
     End
  End
  End

对于不同的困难,你可以做类似的事情

     if L1 then
        Num1 = math.random(3,15)
        Num2 = math.random(3,15
        OpFind = math.random(3)
        If opfind == 1 then
            Operation = "+"
        Elseif opfind == 2 then
            Operation = "-"
         Elseif opfind ==3 then
            Operation = "*"
        End
    ElseIf L2 then 
        num1 = math.random(7,50)
        Num2 = math.random(7,50)
        OpFind = math.random(4)
        If opfind == 1 then
            Operation = "^"
        Elseif opfind == 2 then
            Operation = "%"
         Elseif opfind ==3 then
            Operation = "*"
         Elseif opfind == 4 then
             Operation == "/"
        End
     End

【讨论】:

    猜你喜欢
    • 2016-04-12
    • 2016-07-31
    • 2015-01-07
    • 1970-01-01
    • 2014-05-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-09-07
    相关资源
    最近更新 更多