我正在製作電暈中的遊戲。我想在用戶在物體上滑動手指時發射子彈。他擦得越遠,子彈應該走得越遠。我在這方面做了很多工作,並且在自來水事件中子彈被擊發,有兩個功能啓動子彈和遊戲循環,開始子彈被用來發射子彈,遊戲循環用於翻譯武器,但我無法理解如何瞄準目標使用手指輕掃。請給我任何建議,謝謝... 代碼什麼迄今已取得低於如何在電暈sdk手指滑動的方向上發射子彈
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
你能分享你的成績如何呢? –