背景图片和角色重叠(love2d)

background = love.graphics.newImage("joust.png")
  bird = love.graphics.newImage("bird.png")
  x = 0
  y = 128
  speed = 300

  function love.update(dt)
    if love.keyboard.isDown("d") then
      x = x + (speed * dt)
    end
    if love.keyboard.isDown("a") then
      x = x - (speed * dt)
    end
    if love.keyboard.isDown("w") then
      y = y - (speed * dt)
    end
    if love.keyboard.isDown("s") then
      y = y + (speed * dt)
    end
  end

 function love.draw()
  love.graphics.draw(bird, x, y)
  for i = 0, love.graphics.getWidth() / background:getWidth() do
    for j = 0, love.graphics.getHeight() / background:getHeight() do
      love.graphics.draw(background, i * background:getWidth(), j * background:getHeight())
    end
  end
 end

让我先解释一下,我知道这是很多代码,所以我很抱歉。我正在尝试制作一个角色移动,并且有一个图像作为背景。当我运行程序时,似乎背景会重叠在角色上,你看不见角色。当我删除背景代码时,角色就像它应该一样出现和工作。有人能告诉我我做错了什么吗? 非常感谢

点赞
用户5675002
用户5675002

将 love.draw() 函数重新排列,以便在背景之后画鸟:

function love.draw()
  for i = 0, love.graphics.getWidth() / background:getWidth() do
    for j = 0, love.graphics.getHeight() / background:getHeight() do
      love.graphics.draw(background, i * background:getWidth(), j * background:getHeight())
    end
  end
  love.graphics.draw(bird, x, y)
end
2016-03-05 08:45:51