这是我在love2d中跳跃时的角色。看起来不错但是..
当我到达地面时,它看起来像这样。
我发现它可能与 img 有关,它没有填满整个正方形。所以它简直就是冲出方阵。
那是它应该在的广场,但是由于我对编程很陌生,所以我不知道该怎么做。我一直在寻找解决方案,但找不到一台 ATM。
这是我的爱.load
function love.load()
love.graphics.setBackgroundColor( 204, 255, 204 )
crazy = love.graphics.newImage("player.png")
pwidth = crazy.getWidth
pheight = crazy.getHeight
AdvTiledLoader.path = "maps/"
map = AdvTiledLoader.load("map.tmx")
map:setDrawRange(0, 0, map.width * map.tileWidth, map.height * map.tileHeight)
camera:setBounds(0, 0, map.width * map.tileWidth - love.graphics.getWidth(), map.height * map.tileHeight - love.graphics.getHeight() )
world = {
gravity = 1536,
ground = 512,
}
player = {
x = 256,
y = 256,
x_vel = 0,
y_vel = 0,
jump_vel = -1024,
speed = 512,
flySpeed = 700,
state = "",
h = 32,
w = 32,
standing = false,
}
function player:jump()
if self.standing then
self.y_vel = self.jump_vel
self.standing = false
end
end
function player:right()
self.x_vel = self.speed
end
function player:left()
self.x_vel = -1 * (self.speed)
end
function player:stop()
self.x_vel = 0
end
function player:collide(event)
if event == "floor" then
self.y_vel = 0
self.standing = true
end
if event == "cieling" then
self.y_vel = 0
end
end
还有我的爱.draw
function love.draw()
camera:set()
love.graphics.draw(crazy, player.x , player.y)
love.graphics.setColor( 255, 255, 255 )
map:draw()
camera:unset()
end
如果您需要查看我的碰撞或其他任何内容,请询问,我将其粘贴在下面:)
我真的很感谢你的帮助谢谢!