假設你是使用LÖVE0.8.0+:
選項1:
代碼:
blocks.ground.body = love.physics.newBody(world, 0, blocks.ground.y, "dynamic")
blocks.ground.shape = love.physics.newRectangleShape(500, 50)
blocks.ground.fixture = love.physics.newFixture(blocks.ground.body, blocks.ground.shape)
blocks.ground.color = {86,176,0}
注:在你的代碼love.physics.newFixture(blocks.ground.body, blocks.ground.shape)
從戀愛的網站(1):
objects.ground.fixture = love.physics.newFixture(objects.ground.body, objects.ground.shape) --attach shape to body
從戀愛的網站還(2 ):
objects.ball.fixture = love.physics.newFixture(objects.ball.body, objects.ball.shape, 1) -- Attach fixture to body and give it a density of 1.
在從他們的網站的第二代碼段,他們設置球密度(質量)至1
。同樣,您應該能夠將質量設置爲0
,在這種情況下,重力對物體沒有影響。但是,如果其他對象與您的對象碰撞,質量0
,我不知道什麼類型的時髦行爲可能會發生。
選項2:
另一種選擇是創建一個新的世界的0
比重:
love.physics.setMeter(64) --the height of a meter our worlds will be 64px
worldNoGravity = love.physics.newWorld(0, 0, true)
然後屍體添加到世界:
blocks.ground.body = love.physics.newBody(worldNoGravity , 0, blocks.ground.y, "dynamic")
blocks.ground.shape = love.physics.newRectangleShape(500, 50)
blocks.ground.fixture = love.physics.newFixture(blocks.ground.body, blocks.ground.shape)
blocks.ground.color = {86,176,0}
希望其中之一將爲你工作:)。
你能發表更多的代碼嗎?比如你如何定義這些集合。 –
https://hastebin.com/ofusilozim.lua我知道這不是最好看的代碼,但這是我的第一個lua遊戲之一,所以我仍然在學習 – HamptonM
這很好。它是一種有趣的語言學習。它能夠查看完整的代碼很有用。我建議在您的問題中添加該行,例如**查看完整代碼:** - >鏈接 –