Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
L÷VE for Lua Game Programming

You're reading from   L÷VE for Lua Game Programming If you want to create 2D games for Windows, Linux, and OS X, this guide to the L?ñVE framework is a must. Written for hobbyists and professionals, it will help you leverage Lua for fast and easy game development.

Arrow left icon
Product type Paperback
Published in Sep 2013
Publisher Packt
ISBN-13 9781782161608
Length 106 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
AKINLAJA DAMILARE JOSHUA AKINLAJA DAMILARE JOSHUA
Author Profile Icon AKINLAJA DAMILARE JOSHUA
AKINLAJA DAMILARE JOSHUA
Arrow right icon
View More author details
Toc

The anim8 library


We have already set up our player and collider box; the player object is now collidable, but we need to animate it. Earlier on, we already created animation with quad (Chapter 2, LÖving Up!). Now we'll be using a cleaner and straightforward animation library—anim8 (love2D.org/wiki/anim8). Just as with the bump library and ATL, we are also going to require the anim8 library in main.lua; be sure that you have already downloaded a copy of the library for use and make sure anim8.lua is in the same directory with main.lua.

anim8 = require "anim8"
  1. Set the player character sprite, the same one we loaded in Tiled as the player object:

    playerSprite = love.graphics.newImage("maps/sprite.png")
  2. Set up the character's grid and size (playerSprite:getWidth() and playerSprite:getHeight())"

    local a8 = anim8.newGrid(32,32,playerSprite:getWidth(), playerSprite:getHeight())
  3. Now let's define our animation states:

    playerWalkRight = anim8.newAnimation('loop', a8('1-8',1), 0.1)
    playerJumpRight = anim8...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime