Creation player from png files in directory

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
Grazulex
Prole
Posts: 1
Joined: Sun Sep 22, 2024 12:57 pm

Creation player from png files in directory

Post by Grazulex »

Hello,

I have character made by more png files (one file = one step of the animation....not a spritesheet in this case)
How can I create a animation with this type of configuration ?

I have that until now

Code: Select all

Player.images = {}
    for i = 0, 1 do -- Assuming there are 2 frames
        Player.images[i] = "graphics/character/down_idle/" .. i .. ".png"
    end
    Player.spritesheet = love.graphics.newArrayImage(Player.images)
what is the next steps ?

Thanks
User avatar
dusoft
Party member
Posts: 635
Joined: Fri Nov 08, 2013 12:07 am
Location: Europe usually
Contact:

Re: Creation player from png files in directory

Post by dusoft »

You need to use love.draw() to draw these images.

Just keep the state of animation in a variable, e.g. anim_state=1, increase by 1 in each animation frame (add dt - delta time up to length of animation (e.g. 0.2 seconds), then reset to zero and start new counting for the next frame etc.) in love.update() function. Once you hit maximum number of elements in table (or overall length of the animation), reset anim_state back to 1.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest