2015-03-08 78 views
0

我對編程完全陌生。我已經測試過如何編寫其他類似的東西......但我嘗試在我的「遊戲」中使用動畫。我使用了「AnAl」庫。一切都很好。但是之後我喜歡用「移動」(或者它叫做P),動畫不起作用,字符旋轉。我不知道我需要做什麼...... 我用了Lua語言,順便說一句。AnAl - 奇怪的旋轉

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 

回答

1

我不知道figur在代碼中指的是什麼。

anim的參數:draw應該是x,y,rotation,scalex,scaley。既然你因爲某些原因在參數前加了figur,你就把旋轉設置爲y的位置。

anim:draw(image.x, image.y, image.rotation, 0.5, 0.5)