{"id":15722493,"url":"https://github.com/insality/defold-tweener","last_synced_at":"2026-02-26T05:17:42.273Z","repository":{"id":226754954,"uuid":"769547650","full_name":"Insality/defold-tweener","owner":"Insality","description":"Timer Based Defold Tween Library","archived":false,"fork":false,"pushed_at":"2025-04-04T20:26:20.000Z","size":833,"stargazers_count":45,"open_issues_count":3,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-14T22:09:28.444Z","etag":null,"topics":["defold","defold-extension","defold-library","defold-module","easing-functions","easings","tween","tweener"],"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/Insality.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"insality","ko_fi":"insality","buy_me_a_coffee":"insality"}},"created_at":"2024-03-09T11:45:01.000Z","updated_at":"2025-04-13T16:40:45.000Z","dependencies_parsed_at":"2024-03-27T19:51:04.111Z","dependency_job_id":"3ce36387-382e-4a4f-93fb-a411684c0819","html_url":"https://github.com/Insality/defold-tweener","commit_stats":{"total_commits":11,"total_committers":1,"mean_commits":11.0,"dds":0.0,"last_synced_commit":"8bfba348c62e0434df7dbc96a5e1736f36459b6c"},"previous_names":["insality/defold-tweener"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Insality%2Fdefold-tweener","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Insality%2Fdefold-tweener/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Insality%2Fdefold-tweener/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Insality%2Fdefold-tweener/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Insality","download_url":"https://codeload.github.com/Insality/defold-tweener/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248968914,"owners_count":21191162,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["defold","defold-extension","defold-library","defold-module","easing-functions","easings","tween","tweener"],"created_at":"2024-10-03T22:08:08.894Z","updated_at":"2026-02-26T05:17:42.268Z","avatar_url":"https://github.com/Insality.png","language":"Lua","funding_links":["https://github.com/sponsors/insality","https://ko-fi.com/insality","https://buymeacoffee.com/insality","https://www.buymeacoffee.com/insality"],"categories":[],"sub_categories":[],"readme":"![](media/logo.png)\n\n[![GitHub release (latest by date)](https://img.shields.io/github/v/tag/insality/defold-tweener?style=for-the-badge\u0026label=Release)](https://github.com/Insality/defold-tweener/tags)\n[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/insality/defold-tweener/ci_workflow.yml?style=for-the-badge)](https://github.com/Insality/defold-tweener/actions)\n[![codecov](https://img.shields.io/codecov/c/github/Insality/defold-tweener?style=for-the-badge)](https://codecov.io/gh/Insality/defold-tweener)\n\n[![Github-sponsors](https://img.shields.io/badge/sponsor-30363D?style=for-the-badge\u0026logo=GitHub-Sponsors\u0026logoColor=#EA4AAA)](https://github.com/sponsors/insality) [![Ko-Fi](https://img.shields.io/badge/Ko--fi-F16061?style=for-the-badge\u0026logo=ko-fi\u0026logoColor=white)](https://ko-fi.com/insality) [![BuyMeACoffee](https://img.shields.io/badge/Buy%20Me%20a%20Coffee-ffdd00?style=for-the-badge\u0026logo=buy-me-a-coffee\u0026logoColor=black)](https://www.buymeacoffee.com/insality)\n\n\n# Tweener\n\n**Tweener** - is a single file Lua module for the [Defold](https://defold.com/) game engine. It provides a way to handle manual tweening in your game.\n\n## Features\n\n- **Tweening**: Create tweens for any action your want.\n- **Easing Functions**: Provides a set of easing functions for different types of easings.\n- **Callbacks**: Callbacks for each tween update.\n- **Custom Easings**: Support for custom easing functions.\n- **Custom Update Frequency**: Option to define update frequency for the tween.\n\n## Setup\n\n### [Dependency](https://www.defold.com/manuals/libraries/)\n\nOpen your `game.project` file and add the following line to the dependencies field under the project section:\n\n**[Tweener](https://github.com/Insality/defold-tweener/archive/refs/tags/6.zip)**\n\n```\nhttps://github.com/Insality/defold-tweener/archive/refs/tags/6.zip\n```\n\n### Library Size\n\n\u003e **Note:** The library size is calculated based on the build report per platform\n\n| Platform         | Library Size |\n| ---------------- | ------------ |\n| HTML5            | **3.28 KB**  |\n| Desktop / Mobile | **6.21 KB**  |\n\n\n### Global Update Frequency [Optional]\n\nOptionally, you can setup global default update frequency in your game.project. It's `60` by default.\n\nThis is a global settings for the tweener. You can specify the update frequence parameter in the `tweener.tween` function for special tween operation.\n\nAdd next `tweener` section to your `game.project` in text mode:\n\n```ini\n[tweener]\nupdate_frequency = 60\n```\n\n## API Reference\n\n### Quick API Reference\n\n```lua\n-- Tween function can be a string, a predefined easing function, or a custom easing function\nlocal tween_function = \"linear\" or tweener.linear or go.EASING_LINEAR or gui.EASING_LINEAR or {0, 0.2, 0.4, 0.8, 0.9, 1}\n\nlocal tween = tweener.tween(tween_function, from, to, time, callback, [dt])\ntweener.cancel(tween)\ntweener.set_pause(tween, true)\ntweener.is_paused(tween)\ntweener.is_active(tween)\n\nlocal value = tweener.ease(tween_function, from, to, time, time_elapsed)\n```\n\n### Importing the Module\n\nTo start using the Tweener module in your project, you first need to import it. This can be done with the following line of code:\n\n```lua\nlocal tweener = require(\"tweener.tweener\")\n```\n\n### Functions\n\nThe Tweener module provides two primary functions to work with tweens:\n\n**tweener.tween**\n---\n```lua\ntweener.tween(tween_function, from, to, time, callback, [dt])\n```\n\nThis function initiates a tween operation immediately. Here's how to use it:\n\n- **Parameters:**\n  - `tween_function`: The tween function. You can use one of the predefined easing functions or provide a custom one.\n  - `from`: The starting value of the tween.\n  - `to`: The ending value of the tween.\n  - `time`: The duration of the tween, in seconds.\n  - `callback`: A `function(value, is_final_call, time_elapsed, time_total)` that gets called upon each update of the tween.\n  - `dt` (optional): The time interval for updating the tween, in seconds.\n\n- **Return Value:**\n  - `tween`: A tween object. You can use it to cancel the tween, check if it still running, or pause it.\n\n- **Usage Example:**\n\n```lua\ntweener.tween(tweener.linear, 0, 100, 1.5, function(value, is_final_call)\n\tprint(\"Tween value: \" .. value)\nend)\n\ntweener.tween(go.EASING_OUTSINE, 0, 100, 1.5, function(value, is_final_call)\n\tprint(\"Tween value: \" .. value)\nend)\n\nlocal tween = tweener.tween({0, 0.2, 0.4, 0.8, 0.9, 1}, 0, 100, 1.5, function(value, is_final_call, time_elapsed, time_total)\n\tprint(\"Tween value: \" .. value)\n\tprint(\"Time elapsed: \" .. time_elapsed .. \" from \" .. time_total .. \" seconds\")\nend)\n\n-- You can cancel the tween by calling tweener.cancel\ntweener.cancel(tween)\n```\n\n\n**tweener.ease**\n---\n```lua\ntweener.ease(tween_function, from, to, time, time_elapsed)\n```\n\nThis function calculates the value of the tween at a specific point in time, based on the easing function provided.\n\n- **Parameters:**\n  - `tween_function`: The tween function.\n  - `from`: The starting value of the tween.\n  - `to`: The ending value of the tween.\n  - `time`: The total duration of the tween, in seconds.\n  - `time_elapsed`: The elapsed time since the start of the tween, in seconds.\n\n- **Usage Example:**\n\n```lua\nlocal value = tweener.ease(tweener.inquad, 0, 100, 1.5, 0.75)\nprint(\"The tween value at halfway point is: \", value)\n\nlocal value = tweener.ease(gui.EASING_OUTSINE, 0, 100, 1.5, 0.75)\nprint(\"The tween value at halfway point is: \", value)\n\nlocal value = tweener.ease({0, 0.2, 0.4, 0.8, 0.9, 1}, 0, 100, 1.5, 0.75)\nprint(\"The tween value at halfway point is: \", value)\n```\n\n\n**tweener.cancel**\n---\n```lua\ntweener.cancel([tween])\n```\n\nThis function cancels the tween with the given `tween` object.\n\n- **Parameters:**\n  - `tween`: The tween object to cancel.\n\n- **Return Value:**\n  - `true` if the tween was successfully canceled, `false` otherwise.\n\n- **Usage Example:**\n\n```lua\nlocal tween = tweener.tween(tweener.linear, 0, 100, 1.5, function(value, is_final_call)\n\tprint(\"Tween value: \" .. value)\nend)\n\ntweener.cancel(tween)\n```\n\n\n**tweener.is_paused**\n---\n```lua\ntweener.is_paused(tween)\n```\n\nThis function returns `true` if the tween is paused, `false` otherwise.\n\n- **Parameters:**\n  - `tween`: The tween object to check. It returned from `tweener.tween` function.\n\n- **Return Value:**\n  - `true` if the tween is paused, `false` otherwise.\n\n\n**tweener.set_pause**\n---\n```lua\ntweener.set_pause(tween, is_paused)\n```\n\nThis function sets the pause state of the tween.\n\n- **Parameters:**\n  - `tween`: The tween object to set the pause state. It returned from `tweener.tween` function.\n  - `is_paused`: The new pause state.\n\n- **Return Value:**\n  - `true` if the tween was successfully paused, `false` otherwise.\n\n- **Usage Example:**\n\n```lua\nlocal tween = tweener.tween(tweener.linear, 0, 100, 1.5, function(value, is_final_call)\n\tprint(\"Tween value: \" .. value)\nend)\n\ntweener.set_pause(tween, true)\ntweener.is_paused(tween) -- Returns true\n```\n\n\n**tweener.is_active**\n---\n```lua\ntweener.is_active(tween)\n```\n\nThis function returns `true` if the tween is running, `false` is the tween is finished.\n\n- **Parameters:**\n  - `tween`: The tween object to check. It returned from `tweener.tween` function.\n\n- **Return Value:**\n  - `true` if the tween is running, `false` is the tween is finished.\n\n- **Usage Example:**\n\n```lua\nlocal tween = tweener.tween(tweener.linear, 0, 100, 1.5, function(value, is_final_call)\n\tprint(\"Tween value: \" .. value)\nend)\n\ntweener.is_active(tween) -- Returns true\n-- Wait for 1.5 seconds\ntweener.is_active(tween) -- Returns false\n```\n\n## Tween Functions\n\n| Tweener Constant | Defold Constant | Easing |\n|------------------|-----------------|--------|\n| `tweener.linear` | `go.EASING_LINEAR` | \u003cimg src=\"media/easing_icons/linear.png\" width=\"50\" height=\"50\"\u003e |\n| `tweener.insine` | `go.EASING_INSINE` | \u003cimg src=\"media/easing_icons/insine.png\" width=\"50\" height=\"50\"\u003e |\n| `tweener.inquad` | `go.EASING_INQUAD` | \u003cimg src=\"media/easing_icons/inquad.png\" width=\"50\" height=\"50\"\u003e |\n| `tweener.incubic` | `go.EASING_INCUBIC` | \u003cimg src=\"media/easing_icons/incubic.png\" width=\"50\" height=\"50\"\u003e |\n| `tweener.incirc` | `go.EASING_INCIRC` | \u003cimg src=\"media/easing_icons/incirc.png\" width=\"50\" height=\"50\"\u003e |\n| `tweener.inquart` | `go.EASING_INQUART` | \u003cimg src=\"media/easing_icons/inquart.png\" width=\"50\" height=\"50\"\u003e |\n| `tweener.inquint` | `go.EASING_INQUINT` | \u003cimg src=\"media/easing_icons/inquint.png\" width=\"50\" height=\"50\"\u003e |\n| `tweener.inexpo` | `go.EASING_INEXPO` | \u003cimg src=\"media/easing_icons/inexpo.png\" width=\"50\" height=\"50\"\u003e |\n| `tweener.inback` | `go.EASING_INBACK` | \u003cimg src=\"media/easing_icons/inback.png\" width=\"50\" height=\"50\"\u003e |\n| `tweener.inelastic` | `go.EASING_INELASTIC` | \u003cimg src=\"media/easing_icons/inelastic.png\" width=\"50\" height=\"50\"\u003e |\n| `tweener.inbounce` | `go.EASING_INBOUNCE` | \u003cimg src=\"media/easing_icons/inbounce.png\" width=\"50\" height=\"50\"\u003e |\n| `tweener.outsine` | `go.EASING_OUTSINE` | \u003cimg src=\"media/easing_icons/outsine.png\" width=\"50\" height=\"50\"\u003e |\n| `tweener.outquad` | `go.EASING_OUTQUAD` | \u003cimg src=\"media/easing_icons/outquad.png\" width=\"50\" height=\"50\"\u003e |\n| `tweener.outcubic` | `go.EASING_OUTCUBIC` | \u003cimg src=\"media/easing_icons/outcubic.png\" width=\"50\" height=\"50\"\u003e |\n| `tweener.outcirc` | `go.EASING_OUTCIRC` | \u003cimg src=\"media/easing_icons/outcirc.png\" width=\"50\" height=\"50\"\u003e |\n| `tweener.outquart` | `go.EASING_OUTQUART` | \u003cimg src=\"media/easing_icons/outquart.png\" width=\"50\" height=\"50\"\u003e |\n| `tweener.outquint` | `go.EASING_OUTQUINT` | \u003cimg src=\"media/easing_icons/outquint.png\" width=\"50\" height=\"50\"\u003e |\n| `tweener.outexpo` | `go.EASING_OUTEXPO` | \u003cimg src=\"media/easing_icons/outexpo.png\" width=\"50\" height=\"50\"\u003e |\n| `tweener.outback` | `go.EASING_OUTBACK` | \u003cimg src=\"media/easing_icons/outback.png\" width=\"50\" height=\"50\"\u003e |\n| `tweener.outelastic` | `go.EASING_OUTELASTIC` | \u003cimg src=\"media/easing_icons/outelastic.png\" width=\"50\" height=\"50\"\u003e |\n| `tweener.outbounce` | `go.EASING_OUTBOUNCE` | \u003cimg src=\"media/easing_icons/outbounce.png\" width=\"50\" height=\"50\"\u003e |\n| `tweener.inoutsine` | `go.EASING_INOUTSINE` | \u003cimg src=\"media/easing_icons/inoutsine.png\" width=\"50\" height=\"50\"\u003e |\n| `tweener.inoutquad` | `go.EASING_INOUTQUAD` | \u003cimg src=\"media/easing_icons/inoutquad.png\" width=\"50\" height=\"50\"\u003e |\n| `tweener.inoutcubic` | `go.EASING_INOUTCUBIC` | \u003cimg src=\"media/easing_icons/inoutcubic.png\" width=\"50\" height=\"50\"\u003e |\n| `tweener.inoutcirc` | `go.EASING_INOUTCIRC` | \u003cimg src=\"media/easing_icons/inoutcirc.png\" width=\"50\" height=\"50\"\u003e |\n| `tweener.inoutquart` | `go.EASING_INOUTQUART` | \u003cimg src=\"media/easing_icons/inoutquart.png\" width=\"50\" height=\"50\"\u003e |\n| `tweener.inoutquint` | `go.EASING_INOUTQUINT` | \u003cimg src=\"media/easing_icons/inoutquint.png\" width=\"50\" height=\"50\"\u003e |\n| `tweener.inoutexpo` | `go.EASING_INOUTEXPO` | \u003cimg src=\"media/easing_icons/inoutexpo.png\" width=\"50\" height=\"50\"\u003e |\n| `tweener.inoutback` | `go.EASING_INOUTBACK` | \u003cimg src=\"media/easing_icons/inoutback.png\" width=\"50\" height=\"50\"\u003e |\n| `tweener.inoutelastic` | `go.EASING_INOUTELASTIC` | \u003cimg src=\"media/easing_icons/inoutelastic.png\" width=\"50\" height=\"50\"\u003e |\n| `tweener.inoutbounce` | `go.EASING_INOUTBOUNCE` | \u003cimg src=\"media/easing_icons/inoutbounce.png\" width=\"50\" height=\"50\"\u003e |\n| `tweener.outinsine` | `go.EASING_OUTINSINE` | \u003cimg src=\"media/easing_icons/outinsine.png\" width=\"50\" height=\"50\"\u003e |\n| `tweener.outinquad` | `go.EASING_OUTINQUAD` | \u003cimg src=\"media/easing_icons/outinquad.png\" width=\"50\" height=\"50\"\u003e |\n| `tweener.outincubic` | `go.EASING_OUTINCUBIC` | \u003cimg src=\"media/easing_icons/outincubic.png\" width=\"50\" height=\"50\"\u003e |\n| `tweener.outincirc` | `go.EASING_OUTINCIRC` | \u003cimg src=\"media/easing_icons/outincirc.png\" width=\"50\" height=\"50\"\u003e |\n| `tweener.outinquart` | `go.EASING_OUTINQUART` | \u003cimg src=\"media/easing_icons/outinquart.png\" width=\"50\" height=\"50\"\u003e |\n| `tweener.outinquint` | `go.EASING_OUTINQUINT` | \u003cimg src=\"media/easing_icons/outinquint.png\" width=\"50\" height=\"50\"\u003e |\n| `tweener.outinexpo` | `go.EASING_OUTINEXPO` | \u003cimg src=\"media/easing_icons/outinexpo.png\" width=\"50\" height=\"50\"\u003e |\n| `tweener.outinback` | `go.EASING_OUTINBACK` | \u003cimg src=\"media/easing_icons/outinback.png\" width=\"50\" height=\"50\"\u003e |\n| `tweener.outinelastic` | `go.EASING_OUTINELASTIC` | \u003cimg src=\"media/easing_icons/outinelastic.png\" width=\"50\" height=\"50\"\u003e |\n| `tweener.outinbounce` | `go.EASING_OUTINBOUNCE` | \u003cimg src=\"media/easing_icons/outinbounce.png\" width=\"50\" height=\"50\"\u003e |\n\n\n## Usage\n\nYou can use Tweener to animate scoring text, for example:\n\n\u003cimg src=\"media/tween_text.gif\" width=\"300\"\u003e\n\nThis animation can be created using the following code:\n\n```lua\ntweener.tween(gui.EASING_OUTCIRC, 0, 9999, 2.4, function(value, is_final_call)\n\tgui.set_text(text_score, \"Score: \" .. math.floor(value))\n\n\tif is_final_call then\n\t\tgui.set_scale(text_score, vmath.vector3(1.25, 1.25, 1))\n\t\tgui.animate(text_score, \"scale\", vmath.vector3(1, 1, 1), gui.EASING_OUTBOUNCE, 0.5)\n\tend\nend)\n```\n\nYou can obtain the value of the tween at any point in time with the `tweener.ease` function:\n\n```lua\ntweener.ease(gui.EASING_OUTSINE, 0, 100, 1, 0)    -- Returns 0\ntweener.ease(gui.EASING_OUTSINE, 0, 100, 1, 0.25) -- Returns 38.268343236509\ntweener.ease(gui.EASING_OUTSINE, 0, 100, 1, 0.5)  -- Returns 70.710678118655\ntweener.ease(gui.EASING_OUTSINE, 0, 100, 1, 0.75) -- Returns 92.387953251129\ntweener.ease(gui.EASING_OUTSINE, 0, 100, 1, 1)    -- Returns 100\n```\n\n\n## License\n\nThis project is licensed under the MIT License - see the LICENSE file for details.\n\n\n## Issues and suggestions\n\nIf you have any issues, questions or suggestions please [create an issue](https://github.com/Insality/defold-tweener/issues).\n\n\n## 👏 Contributors\n\n\u003ca href=\"https://github.com/Insality/defold-tweener/graphs/contributors\"\u003e\n  \u003cimg src=\"https://contributors-img.web.app/image?repo=insality/defold-tweener\"/\u003e\n\u003c/a\u003e\n\n\n## Changelog\n\u003cdetails\u003e\n\n### **V1**\n- Initial release\n\n### **V2**\n- Changed timer `delta time` to `socket.gettime` for more precise tweening\n\n### **V3**\n- Added custom easings support\n\n### **V4**\n- Fix `update_frequency` game.project settings typo\n- Now able to use string name of easing functions (ex. \"linear\", \"insine\", \"outquad\", etc.)\n- Add `tweener.cancel` function to cancel tweening instead of `timer.cancel` (For better API and README)\n- Code cleanup and better performance\n- Fix if total time is 0, then callback will be called immediately\n\n### **V5**\n- [Breaking]: `tweener.tween` now returns a tween object instead of a timer id. So if you used `timer.cancel` to cancel the tween, you need to use `tweener.cancel` instead.\n- Added `tweener.set_pause` function to pause and resume a tween\n- Added `tweener.is_paused` function to check if a tween is paused\n- Added `tweener.is_active` function to check if a tween is active\n\n### **V6**\n- Add `time_elapsed` and `time_total` parameters to the tween callback function\n- The `tweener.cancel` now can be called with a `nil` object to escape the additional `if` check\n\n\u003c/details\u003e\n\n\n## ❤️ Support project ❤️\n\nYour donation helps me stay engaged in creating valuable projects for **Defold**. If you appreciate what I'm doing, please consider supporting me!\n\n[![Github-sponsors](https://img.shields.io/badge/sponsor-30363D?style=for-the-badge\u0026logo=GitHub-Sponsors\u0026logoColor=#EA4AAA)](https://github.com/sponsors/insality) [![Ko-Fi](https://img.shields.io/badge/Ko--fi-F16061?style=for-the-badge\u0026logo=ko-fi\u0026logoColor=white)](https://ko-fi.com/insality) [![BuyMeACoffee](https://img.shields.io/badge/Buy%20Me%20a%20Coffee-ffdd00?style=for-the-badge\u0026logo=buy-me-a-coffee\u0026logoColor=black)](https://www.buymeacoffee.com/insality)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finsality%2Fdefold-tweener","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finsality%2Fdefold-tweener","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finsality%2Fdefold-tweener/lists"}