【问题标题】:How to remove bullets using corona sdk如何使用 corona sdk 移除子弹
【发布时间】:2014-01-19 11:04:53
【问题描述】:

我想在子弹射击后移除子弹,就在我的过渡之后。这是我的代码:

local bullet
local function shootf (event)

  bullet = display.newRect(w/2, h/2, 15, 15)
  physics.addBody( bullet, "static")
  transition.to( bullet, {time = speed, x = bulletX, y = bulletY})
  print( "bullet shot" )
end

shoot:addEventListener("tap", shootf)

如何才能正确移除子弹?我尝试了几件事,但我不知道如何处理 de remove 函数。

【问题讨论】:

    标签: lua coronasdk


    【解决方案1】:

    如下更改您的transition.to,然后运行应用程序:

    transition.to( bullet, {time = speed,
                             x = bulletX,
                             y = bulletY,
                             onComplete=function() bullet:removeSelf() end end})
    

    继续编码...... :)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-08-29
      • 2014-06-16
      • 1970-01-01
      • 1970-01-01
      • 2014-03-24
      • 1970-01-01
      相关资源
      最近更新 更多