{"id":15104022,"url":"https://github.com/guilleatm/animations","last_synced_at":"2026-02-26T10:34:51.032Z","repository":{"id":52644851,"uuid":"307685298","full_name":"guilleatm/animations","owner":"guilleatm","description":"Make animations in Löve2d easily","archived":false,"fork":false,"pushed_at":"2021-04-22T14:08:46.000Z","size":25,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-30T14:38:09.040Z","etag":null,"topics":["game-development","gamedev","love2d","love2d-framework","love2d-library","lua"],"latest_commit_sha":null,"homepage":"","language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/guilleatm.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-10-27T12:00:17.000Z","updated_at":"2021-04-22T14:08:49.000Z","dependencies_parsed_at":"2022-08-22T01:20:52.794Z","dependency_job_id":null,"html_url":"https://github.com/guilleatm/animations","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/guilleatm/animations","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guilleatm%2Fanimations","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guilleatm%2Fanimations/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guilleatm%2Fanimations/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guilleatm%2Fanimations/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/guilleatm","download_url":"https://codeload.github.com/guilleatm/animations/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guilleatm%2Fanimations/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29856737,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-26T08:51:08.701Z","status":"ssl_error","status_checked_at":"2026-02-26T08:50:19.607Z","response_time":89,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["game-development","gamedev","love2d","love2d-framework","love2d-library","lua"],"created_at":"2024-09-25T20:00:27.563Z","updated_at":"2026-02-26T10:34:51.013Z","avatar_url":"https://github.com/guilleatm.png","language":"Lua","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Animations\n\n## Description\n\nCreate animations in Löve2d easily with this small library. Read the documentation for using the functionalities.\n\nThe library was made following the [Löve2D animation tutorial](https://love2d.org/wiki/Tutorial:Animation).\n\n\u003e Of course you have to add the file 'Animation.lua' in your project, remember to add the 'require' statement too.\n\n---\n\n## Overview\n\n| Methods\t| Description\t\t\t\t| Required parameters\t\t\t\t| Returns\t\t|\n| -:\t\t| ------------------------------------- | --------------------------------------------- | --------------------- |\n| new()\t\t| Creates a new animation (Constructor)\t| image_or_path, sprite_width, sprite_height\t| Animation\t\t|\n| update()\t| Updates the animation\t\t\t| delta_time\t\t\t\t\t| null (nothing)\t|\n| draw()\t| Draws the animation\t\t\t| x_position, y_position\t\t\t| null (nothing)\t|\n| start()\t| Starts the animation\t(see more)\t|\t\t\t\t\t\t| null (nothing)\t|\n| stop()\t| Stops the animation (see more)\t|\t\t\t\t\t\t| null (nothing)\t|\n| restart()\t| Restarts the animation (from frame 0)\t|\t\t\t\t\t\t| null (nothing)\t|\n| setScale()\t| Sets the animation scale\t\t| new_scale\t\t\t\t\t| null (nothing)\t|\n| addCallback()\t| Adds a callback in the desired frame\t| frame_index, function\t\t\t\t| null (nothing)\t|\n\n\n\n\n## Creating an animation\n\n```Animation:new(image_or_path, sprite_width, sprite_height)```  Minimum required\n\n```Animation:new(image_or_path, sprite_width, sprite_height, animation_duration, loop, x_offset, y_offset)```\n\n* **image_or_path**: An image object (love.graphics.newImage(imagePath)) or the path to the image. The image have to be a spritesheet with all the sprites in the same row, see the *oldHero.png*.\n* **sprite_width**: The width of the sprite.\n* **sprite_height**: The height of the sprite.\n* **animation_duration**: The duration of the animation, when lower, quicker the animation (default is 1 second).\n* **loop**: True if the animation have to loop, false if not (default is false).\n* **x_offet**: The x offset (default is the sprite_width / 2).\n* **y_offet**: The y offset (default is the sprite_height / 2).\n\n### Creating an animation example:\n\n```lua\nimg = love.graphics.newImage(\"oldHero.png\") -- Sprite size --\u003e 16 x 18\nanimation = Animation:new(img, 16, 18, 0.5, true)\n\n-- YOU CAN PASS AS ARGUMENT AN IMAGE OR THE PATH TO THE IMAGE, the result is the same.\n\nanimation = Animation:new(\"oldHero.png\", 16, 18, 0.5, true)\n```\n\n---\n\n## Updating the animation\n\n```Animation:update(dt)```\n\n* **dt**: Delta time, time between two frames. Use love.update(dt). You can get it by calling love.timer.getDelta() too.\n\n---\n\n## Drawing the animation\n\n```Animation:draw(x, y)```\n\n* **x**: The x position where the animation have to be drawn.\n* **y**: The y position where the animation have to be drawn.\n\n\u003e If x_offset and y_offset were ignored (default) the animation will be centered.\n\n---\n\n## Starting the animation\n\n```Animation:start()```\n\n\u003e If the animation is stopped and then started, it will continue. Won't be restarted, see (Restarting the animation).\n\n---\n\n## Stopping the animation\n\n```Animation:stop()``` Minimum required\n\n```Animation:stop(n_frame)```\n\n* **n_frame**: The frame (sprite) that the animation will mantain after stopped (int)\n\n---\n\n## Restarting the animation\n\n```Animation:restart()```\n\n\u003e By restarting the animation you make sure that the animation starts from frame zero.\n\n---\n\n## Changing the scale\n\n```Animation:setScale(new_scale)```\n\n* **new_scale**: New animation scale\n\n---\n\n## Adding callbacks\n\n```Animation:addCallback(n_frame, function)```\n\n\u003e Every time the animation reaches the frame *n_frame*, function will be called.\n\n* **n_frame**: The frame in wich the function will be called.\n* **function**: The called function.\n\n### Adding callbacks example\n\n```lua\n\nfunction notice()\n\tprint(\"I am called in the frame 5!!\")\nend\n\nanimation:addCallback(5, notice)\n\n-- THE SAME, SHORTER\n\nanimation:addCallback(5, function() print(\"I am called in the frame 5!!\") end)\n\n```\n\n# Example\n\n```lua\n-- main.lua\n\nlocal Animation = require 'Animation'\n\n\nfunction love.load()\n\tlove.graphics.setDefaultFilter(\"nearest\", \"nearest\") -- Not necessary, sets the correct filter for loading pixelart images.\n\n\tlocal img = love.graphics.newImage(\"oldHero.png\") -- Sprite size --\u003e 16 x 18\n\tmyAnimation = Animation:new(img, 16, 18, 0.5, true) -- The animation takes 0.5 seconds and loops until myAnimation:stop()\n\tmyAnimation:setScale(8) -- The drawn image is 8 times bigger than the real size.\n\tmyAnimation:addCallback(5, function() print(\"I am called in the frame 5!!\") end) -- Each time the animation reaches the 5 frame, this function is called.\n\n\tmyAnimation:start() -- Starts the animation.\nend\n\n\n\nfunction love.update(dt)\n\tmyAnimation:update(dt) -- Remember the update and the draw!!\nend\n\n\nfunction love.draw()\n\tmyAnimation:draw(200, 200) -- Remember the update and the draw!!\nend\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fguilleatm%2Fanimations","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fguilleatm%2Fanimations","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fguilleatm%2Fanimations/lists"}