function love.load()
frame={}
table.insert(frame,love.graphics.newImage("jump1.png"))
table.insert(frame,love.graphics.newImage("jump2.png"))
table.insert(frame,love.graphics.newImage("jump3.png"))
table.insert(frame,love.graphics.newImage("jump4.png"))
table.insert(frame,love.graphics.newImage("jump5.png"))
end
function love.update()
end
function love.draw()
love.graphics.draw(frame[1],100,100)
end
function love.load()
--[[
frame={}
table.insert(frame,love.graphics.newImage("jump1.png"))
table.insert(frame,love.graphics.newImage("jump2.png"))
table.insert(frame,love.graphics.newImage("jump3.png"))
table.insert(frame,love.graphics.newImage("jump4.png"))
table.insert(frame,love.graphics.newImage("jump5.png"))
--]]
frame={}
for i=1,5
do
table.insert(frame,love.graphics.newImage("jump"..i..".png"))
end
end
function love.update()
end
function love.draw()
love.graphics.draw(frame[1],100,100)
end
function love.load()
--[[
frame={}
table.insert(frame,love.graphics.newImage("jump1.png"))
table.insert(frame,love.graphics.newImage("jump2.png"))
table.insert(frame,love.graphics.newImage("jump3.png"))
table.insert(frame,love.graphics.newImage("jump4.png"))
table.insert(frame,love.graphics.newImage("jump5.png"))
--]]
frame={}
for i=1,5
do
table.insert(frame,love.graphics.newImage("jump"..i..".png"))
end
--我使用了一个长名字,以避免与变量frame混淆
currentFrame=1
end
function love.update(dt)
currentFrame=currentFrame+dt
end
function love.draw()
love.graphics.draw(frame[currentFrame],100,100)
end
function love.load()
--[[
frame={}
table.insert(frame,love.graphics.newImage("jump1.png"))
table.insert(frame,love.graphics.newImage("jump2.png"))
table.insert(frame,love.graphics.newImage("jump3.png"))
table.insert(frame,love.graphics.newImage("jump4.png"))
table.insert(frame,love.graphics.newImage("jump5.png"))
--]]
frame={}
for i=1,5
do
table.insert(frame,love.graphics.newImage("jump"..i..".png"))
end
--我使用了一个长名字,以避免与变量frame混淆
currentFrame=1
end
function love.update(dt)
currentFrame=currentFrame+dt
end
function love.draw()
love.graphics.draw(frame[1],100,100)
love.graphics.print(currentFrame,200,200)
end
function love.load()
--[[
frame={}
table.insert(frame,love.graphics.newImage("jump1.png"))
table.insert(frame,love.graphics.newImage("jump2.png"))
table.insert(frame,love.graphics.newImage("jump3.png"))
table.insert(frame,love.graphics.newImage("jump4.png"))
table.insert(frame,love.graphics.newImage("jump5.png"))
--]]
frame={}
for i=1,5
do
table.insert(frame,love.graphics.newImage("jump"..i..".png"))
end
--我使用了一个长名字,以避免与变量frame混淆
currentFrame=1
end
function love.update(dt)
currentFrame=currentFrame+dt
end
function love.draw()
love.graphics.draw(frame[math.floor(currentFrame)],100,100)
love.graphics.print(currentFrame,200,200)
end
function love.load()
--[[
frame={}
table.insert(frame,love.graphics.newImage("jump1.png"))
table.insert(frame,love.graphics.newImage("jump2.png"))
table.insert(frame,love.graphics.newImage("jump3.png"))
table.insert(frame,love.graphics.newImage("jump4.png"))
table.insert(frame,love.graphics.newImage("jump5.png"))
--]]
frame={}
for i=1,5
do
table.insert(frame,love.graphics.newImage("jump"..i..".png"))
end
--我使用了一个长名字,以避免与变量frame混淆
currentFrame=1
end
function love.update(dt)
currentFrame=currentFrame+10*dt
if currentFrame>=6
then
currentFrame=1
end
end
function love.draw()
love.graphics.draw(frame[math.floor(currentFrame)],100,100)
love.graphics.print(currentFrame,200,200)
end
function love.load()
image=love.graphics.newImage("jump.png")
end
function love.update(dt)
end
function love.draw()
love.graphics.draw(image,100,100)
end
function love.load()
image=love.graphics.newImage("jump.png")
frame={}
width=image:getWidth()
height=image:getHeight()
table.insert(frame,love.graphics.newQuad(0,0,width/5,height,width,height))
currentFrame=1
end
function love.update(dt)
end
function love.draw()
love.graphics.draw(image,100,100)
love.graphics.print(width,200,200)
love.graphics.print(height,300,300)
end
function love.load()
image=love.graphics.newImage("jump.png")
frame={}
width=image:getWidth()
height=image:getHeight()
table.insert(frame,love.graphics.newQuad(0,0,width/5,height,width,height))
currentFrame=1
end
function love.update(dt)
end
function love.draw()
love.graphics.draw(image,frame[1],100,100)
love.graphics.print(width,200,200)
love.graphics.print(height,300,300)
end
--[[
function love.load()
--[[
frame={}
table.insert(frame,love.graphics.newImage("jump1.png"))
table.insert(frame,love.graphics.newImage("jump2.png"))
table.insert(frame,love.graphics.newImage("jump3.png"))
table.insert(frame,love.graphics.newImage("jump4.png"))
table.insert(frame,love.graphics.newImage("jump5.png"))
--]]
--[[
frame={}
for i=1,5
do
table.insert(frame,love.graphics.newImage("jump"..i..".png"))
end
--我使用了一个长名字,以避免与变量frame混淆
currentFrame=1
end
function love.update(dt)
currentFrame=currentFrame+10*dt
if currentFrame>=6
then
currentFrame=1
end
end
function love.draw()
love.graphics.draw(frame[math.floor(currentFrame)],100,100)
love.graphics.print(currentFrame,200,200)
end
--]]
function love.load()
image=love.graphics.newImage("jump.png")
frame={}
width=image:getWidth()
height=image:getHeight()
table.insert(frame,love.graphics.newQuad(0,0,width/5,height,width,height))
table.insert(frame,love.graphics.newQuad(width/5,0,width/5,height,width,height))
currentFrame=1
end
function love.update(dt)
end
function love.draw()
love.graphics.draw(image,frame[2],100,100)
love.graphics.print(width,200,200)
love.graphics.print(height,300,300)
end
function love.load()
image=love.graphics.newImage("jump.png")
frame={}
width=image:getWidth()
height=image:getHeight()
table.insert(frame,love.graphics.newQuad(0,0,width/5,height,width,height))
table.insert(frame,love.graphics.newQuad(width/5,0,width/5,height,width,height))
table.insert(frame,love.graphics.newQuad(width/5*2,0,width/5,height,width,height))
currentFrame=1
end
function love.update(dt)
end
function love.draw()
love.graphics.draw(image,frame[3],100,100)
love.graphics.print(width,200,200)
love.graphics.print(height,300,300)
end
function love.load()
image=love.graphics.newImage("jump.png")
frame={}
width=image:getWidth()
height=image:getHeight()
--[[
table.insert(frame,love.graphics.newQuad(0,0,width/5,height,width,height))
table.insert(frame,love.graphics.newQuad(width/5,0,width/5,height,width,height))
table.insert(frame,love.graphics.newQuad(width/5*2,0,width/5,height,width,height))
--]]
for i=0,4
do
table.insert(frame,love.graphics.newQuad(i*width/5,0,width/5,height,width,height))
end
currentFrame=1
end
function love.update(dt)
currentFrame=currentFrame+10*dt
if currentFrame>=6
then
currentFrame=1
end
end
function love.draw()
love.graphics.draw(image,frame[math.floor(currentFrame)],100,100)
love.graphics.print(width,200,200)
love.graphics.print(height,300,300)
end
function love.load()
image = love.graphics.newImage("jump_2.png")
local width = image:getWidth()
local height = image:getHeight()
frame = {}
local frame_width = 117
local frame_height = 233
for i=0,2 do
table.insert(frame, love.graphics.newQuad(i * frame_width, 0, frame_width, frame_height, width, height))
end
for i=0,1 do
table.insert(frame, love.graphics.newQuad(i * frame_width, frame_height, frame_width, frame_height, width, height))
end
--[[
for i=0,1 do
--I changed i to j in the inner for-loop
for j=0,2 do
--Meaning you also need to change it here
table.insert(frame, love.graphics.newQuad(j * frame_width, i * frame_height, frame_width, frame_height, width, height))
end
end
--]]
currentFrame = 1
end
function love.update(dt)
currentFrame=currentFrame+10*dt
-- if currentFrame>=6
-- then
-- currentFrame=1
-- end
end
function love.draw()
love.graphics.draw(image,frame[math.floor(currentFrame)],100,100)
end
function love.load()
image = love.graphics.newImage("jump_2.png")
local width = image:getWidth()
local height = image:getHeight()
frame = {}
local frame_width = 117
local frame_height = 233
--[[
for i=0,2 do
table.insert(frame, love.graphics.newQuad(i * frame_width, 0, frame_width, frame_height, width, height))
end
for i=0,1 do
table.insert(frame, love.graphics.newQuad(i * frame_width, frame_height, frame_width, frame_height, width, height))
end
--]]
for i=0,1 do
--I changed i to j in the inner for-loop
for j=0,2 do
--Meaning you also need to change it here
table.insert(frame, love.graphics.newQuad(j * frame_width, i * frame_height, frame_width, frame_height, width, height))
end
end
currentFrame = 1
end
function love.update(dt)
currentFrame=currentFrame+10*dt
-- if currentFrame>=6
-- then
-- currentFrame=1
-- end
end
function love.draw()
love.graphics.draw(image,frame[math.floor(currentFrame)],100,100)
end
function love.load()
image = love.graphics.newImage("jump_2.png")
local width = image:getWidth()
local height = image:getHeight()
frame = {}
local frame_width = 117
local frame_height = 233
--[[
for i=0,2 do
table.insert(frame, love.graphics.newQuad(i * frame_width, 0, frame_width, frame_height, width, height))
end
for i=0,1 do
table.insert(frame, love.graphics.newQuad(i * frame_width, frame_height, frame_width, frame_height, width, height))
end
--]]
for i=0,1 do
--I changed i to j in the inner for-loop
for j=0,2 do
--Meaning you also need to change it here
table.insert(frame, love.graphics.newQuad(j * frame_width, i * frame_height, frame_width, frame_height, width, height))
end
end
currentFrame = 1
end
function love.update(dt)
currentFrame=currentFrame+10*dt
if currentFrame>=6
then
currentFrame=1
end
end
function love.draw()
love.graphics.draw(image,frame[math.floor(currentFrame)],100,100)
end
newQuad(1, 1, frame_width, frame_height, width, height)
newQuad(1 + j * frame_width, 1 + i * frame_height, frame_width, frame_height, width, height)
newQuad(1 + j * (frame_width + 2), 1 + i * (frame_height + 2), frame_width, frame_height, width, height)
以上就是今天要讲的内容,本文仅仅简单介绍了Love2d动画(Animation)的使用,与博主的lua语言文章结合更好的理解love2d的编码,如果你是一名独立游戏开发者,或者一位对游戏开发有着深厚兴趣,但是又对于unity3d,ue4等这些对于新手而言不太友好的引擎而头疼的开发者;那么现在,你可以试试Love2D。Love2D是一款基于Lua编写的轻量级游戏框架,尽管官方称呼其为引擎,但实际上它只能称得上是一个框架,因为他并没有一套全面完整的解决方案。不过,这款框架上手及其容易,是学习游戏开发的初学者入门的一个良好选择。
创作打卡挑战赛
赢取流量/现金/CSDN周边激励大奖
版权说明 : 本文为转载文章, 版权归原作者所有 版权申明
原文链接 : https://blog.csdn.net/qq_44918090/article/details/124725465
内容来源于网络,如有侵权,请联系作者删除!