The animation algorithm will simply play the sprite like a tape of film; we'll be using a basic technique here as LÖve doesn't have an official module for that. Some members of the LÖve forum have come up with different libraries to ease the way we play animations. The use of animation libraries will come up in later chapters. First of all let us load our file:
Then we create quads for each part of the sprite by using love.graphics.newQuad(x, y, width, height, sw, sh)
, where x
is the top-left position of the quad along the x axis, y
is the top-left position of the quad along the y axis, width
is the width of the quad, height
is the height of the quad, sw
is the sprite's width, and sh
is the sprite's height: