使用 Corona SDK 的气球游戏

我完全是初学者,要开发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个气球重复相同的功能(另一种混乱)?我将为所有人使用相同的声音。

非常感谢您的反馈。

原文链接 https://stackoverflow.com/questions/9654343

点赞
stackoverflow用户2114015
stackoverflow用户2114015

如果你想要多个气球,使用表格将会要容易得多。你可以轻松地拥有任意数量的气球。

balloons = {} -- 追踪所有气球
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) do
        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
2013-02-27 05:57:18