【发布时间】:2017-12-03 17:16:33
【问题描述】:
所以我正在尝试制作 Flappy Birdesque 游戏来学习如何使用 Corona SDK 制作游戏。我有一个顶栏,我希望能够线性移动。所以我使用topColumn.setLinearVelocity(),但我也在游戏中设置了重力,所以小鸟可以正常拍打:)。但我的问题是,当游戏开始时,由于重力,管道会掉到地上。有没有办法在不受重力影响的情况下移动 topColumn 和 bottomColumn ?它们现在是动态物体,但我不知道如何使用静态来移动它们。
有什么帮助吗?
local physics = require "physics"
physics.start()
physics.setGravity( 0, 100 )
...
function addColumns()
height = math.random(display.contentCenterY - 200, display.contentCenterY + 200)
topColumn = display.newImageRect('topColumn.png',100,714)
topColumn.anchorX = 0.5
topColumn.anchorY = 1
topColumn.x = display.contentWidth
physics.addBody(topColumn, "dynamic", {density=0, bounce=0, friction=0})
topColumn.y = height - 160
topColumn:setLinearVelocity( -20,0 )
bottomColumn = display.newImageRect('bottomColumn.png',100,714)
bottomColumn.anchorX = 0.5
bottomColumn.anchorY = 0
bottomColumn.x = display.contentWidth
bottomColumn.y = height + 160
physics.addBody(bottomColumn, "dynamic", {density=0, bounce=0, friction=0})
bottomColumn:setLinearVelocity( -20,0 )
end
...
【问题讨论】:
标签: android lua coronasdk game-physics