【发布时间】:2014-10-04 03:14:38
【问题描述】:
我正在使用 corona sdk 制作一个游戏,其中星星随机从屏幕上掉下来,直到用户输掉,请看代码:
local composer = require( "composer" )
local scene = composer.newScene()
local createstar = {}
local stars = {}
local timer
local b
local update = {}
local wait = {}
local ie = - 150
function scene:create( event )
local sceneGroup = self.view
end
function scene:show( event )
local sceneGroup = self.view
local phase = event.phase
if phase == "will" then
elseif phase == "did" then
stars = display.newGroup()
function wait( event )
timer = timer.performWithDelay( 100, createstar, 0)
Runtime:addEventListener('enterFrame', update)
end
timer.performWithDelay( 200, wait)
function createstar()
ie = ie - 300
astar = display.newImage('star.png', math.random( 1, 10) * 33, ie)
stars:insert(astar)
sceneGroup:insert(stars)
end
function update(e)
if(stars ~= nil)then
for i = 1, stars.numChildren do
stars[i].y = stars[i].y + 3
end
end
end
end
end
function scene:hide( event )
local sceneGroup = self.view
local phase = event.phase
if event.phase == "will" then
elseif phase == "did" then
end
end
function scene:destroy( event )
local sceneGroup = self.view
end
scene:addEventListener( "create", scene )
scene:addEventListener( "show", scene )
scene:addEventListener( "hide", scene )
scene:addEventListener( "destroy", scene )
return scene
现在要让我的游戏正常运行,我需要能够在每颗星之间画线。也就是说,我需要玩家触摸每颗星星,当他这样做时,在他触摸的星星和他之前触摸的星星之间会产生一条线。我知道如何画线,但不确定如何在使用函数创建的两个对象之间画线。有谁知道如何做到这一点?提前致谢!
【问题讨论】:
标签: lua touch line coronasdk draw