0
我试图在我的函数中停止3个动画,当它达到某个点时,然后显示消息“动画已停止”。需要帮助停止corona的功能
我该怎么做?我知道display.NewText()
,但我会如何去停止动画并让消息同时弹出?
这是我试图阻止的功能。
WIDTH = display.contentWidth
HEIGHT = display.contentHeight
--displays background
local s = display.newImageRect("space.png" ,1136, 640)
s.x = 900/2
s.y = 500/2
--display main ship
local r = display.newImageRect("ship.png", 70, 70)
r.x = 20
r.y = 450
local minions = {}
function createMinions()
local x = 40
local y = 120
for n = 1, 20 do -- displays 20 minions
local minion = display.newImageRect("minion.png", 50, 50)
minion.x = x
minion.y = y
minions[n] = minion
x = x + 60 -- next enemy will be to the right
if x >= WIDTH then -- start a new row if necessary
y = y + 60 -- seperation between minions
x = 40
end
end
end
--display mothership
m = display.newImageRect("mothership.png", 150, 150)
m.x = 160
m.y = 10
function nextFrame()
-- begins movements of main ship to right
r.x = r.x + 5
if r.x > 350 then
r.x = -100
end
-- begins movement of minions to the left
for i = 1, 20 do
local minion = minions[i]
minion.x = minion.x - 8
if minion.x < -100 then
minion.x = 400
end
end
--begins movement of mothership towards small ship
m.y = m.y + 10
if m.y > 460 then
m.y = -100
end
--stops all animations
if m.y > 450 then
--r.x = r.x + 0
--m.y = m.y + 0
--minion.x = minion.x + 0
local s = true
--displays game over text
s = display.newText("Game Over", WIDTH/2, 400, native, 30)
end
end
createMinions()
Runtime:addEventListener("enterFrame", nextFrame)
--hides status bar
display.setStatusBar(display.HiddenStatusBar)
你是什么意思,你试图“停止”它?只是停止调用它?你需要告诉我们你在哪里打电话给我们,告诉你如何阻止它。 – 2014-09-13 10:46:27
好吧刚从corona发布了整个脚本。我只是想让我的动画中的所有对象在m.y> 450时立即停止,并将游戏显示为符号 – Chris 2014-09-13 17:08:37
只需在'if(m.y <450),然后YOURCODE结束' – 2014-09-13 18:20:15