【发布时间】:2013-07-15 00:37:36
【问题描述】:
我正在开发一款电晕游戏。当用户在对象上滑动手指时,我想发射子弹。他扫得越远,子弹应该走得越远。我对此进行了研究,并在点击事件时发射了子弹,有两个功能启动弹丸和游戏循环,开始弹丸用于发射弹丸,游戏循环用于翻译武器,但我不明白如何瞄准使用手指滑动的目标。请给我任何建议,谢谢... 到目前为止已经实现的代码如下
local function startprojectile(event)
gameIsActive=true
local firetimer
local getobj=event.target
local getxloc=getobj.x
local getyloc=getobj.y
local function firenow()
if gameIsActive=false then
timer.cancel(firetimer)
firetimer=nil
else
local bullet=display.newImageRect("object.png",50,60);
bullet.x=getxloc-50; bullet.y=getyloc-50
bullet.type=bullet1
physics.addBody(bullet,{isSensor=true})
weaponGroup:insert(bullet)
end
gameIsActive=false
end
firetimer.timer.performWithDelay(650,firenow)
end
local function gameloop()
local i
for i=weaponGroup.numChildren,1,-1 do
local weapon=weaponGroup[i]
if weapon ~=nil and weapon.x ~=nil
then
weapon:translate(-20,0)
end
end
【问题讨论】:
-
您能分享一下您目前取得的成就吗?