AnAl - 奇怪的旋转

我完全是个编程新手。我已经尝试了如何编写脚本,以及其他一些东西……但是我尝试在我的“游戏”中使用动画。我使用了“AnAl”库。一切都运作得很好。但是,当我想要使用“移动”(或类似的功能)时,动画不起作用,角色也会旋转。我不知道该怎么办……顺便说一下,我使用的是 Lua 语言。

require ("AnAl")

function love.load()
    -- Shortcuts
    lg = love.graphics
    lkid = love.keyboard.isDown

    local img = lg.newImage ("img.png")
    anim = newAnimation(img, 100, 100, 0.1,5,0)
    image = {
        x = 250,
        y = 150,
        rotation = math.rad (0),
        moveSpeed = 200
    }
end

function love.draw()
    anim:draw(figur, image.x, image.y, image.rotaion, 0.5, 0.5)
end

function love.update(dt)
    if lkid("w") then image.y = image.y - image.moveSpeed * dt end
    if lkid("s") then image.y = image.y + image.moveSpeed * dt end
    if lkid("a") then image.x = image.x - image.moveSpeed * dt end
    if lkid("d") then image.x = image.x + image.moveSpeed * dt end
    anim:update(dt)
end
点赞
用户4648708
用户4648708

我不知道您代码中的 "figur" 指的是什么。

anim:draw 的参数应该是 x、y、rotation、scalex 和 scaley。由于您以某种原因在参数之前添加了 "figur",所以您将旋转设置为 y 位置。

anim:draw(image.x, image.y, image.rotation, 0.5, 0.5)
2015-03-09 09:33:00