{"id":13622125,"url":"https://github.com/mjtalbot/rive_piggy","last_synced_at":"2025-04-15T05:33:40.413Z","repository":{"id":45648916,"uuid":"413731832","full_name":"mjtalbot/rive_piggy","owner":"mjtalbot","description":"Rive Piggy Bank for https://rive.app/community/873-2021-piggy-bank/","archived":false,"fork":false,"pushed_at":"2023-05-30T14:57:24.000Z","size":124,"stargazers_count":5,"open_issues_count":2,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-11-08T09:41:44.205Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mjtalbot.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2021-10-05T08:20:42.000Z","updated_at":"2024-07-19T19:31:46.000Z","dependencies_parsed_at":"2024-08-01T21:54:24.899Z","dependency_job_id":null,"html_url":"https://github.com/mjtalbot/rive_piggy","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mjtalbot%2Frive_piggy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mjtalbot%2Frive_piggy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mjtalbot%2Frive_piggy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mjtalbot%2Frive_piggy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mjtalbot","download_url":"https://codeload.github.com/mjtalbot/rive_piggy/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249015965,"owners_count":21198824,"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":[],"created_at":"2024-08-01T21:01:14.477Z","updated_at":"2025-04-15T05:33:40.085Z","avatar_url":"https://github.com/mjtalbot.png","language":"Kotlin","funding_links":[],"categories":["Advanced"],"sub_categories":["Sync Sounds at runtime"],"readme":"# rive_piggy\n\nThis is a sample Rive app for Android. \n\nThe [RiveAnimationView](https://github.com/rive-app/rive-android/blob/master/kotlin/src/main/java/app/rive/runtime/kotlin/RiveAnimationView.kt) view is great for simple use cases, but in this example we want to shows how to use the [core](https://github.com/rive-app/rive-android/tree/master/kotlin/src/main/java/app/rive/runtime/kotlin/core) parts of the animation library to make a custom animation loop with far more control!\n\n# App sample gif\n\n![piggy](https://user-images.githubusercontent.com/1216025/135996961-661949f8-974e-4f22-a9bc-adbb4a6e45cb.gif) \n\n# Animation file setup file set up \n\nThe [Piggy.riv](https://github.com/mjtalbot/rive_piggy/tree/main/app/src/main/res/raw/piggy.riv) file is split into 3 artboards\n\n- Background\n- Piggy\n  - has a state machine \"PiggyMachine\" with a \"Pressed\" trigger input. The trigger input switches the pig from running the \"idle\" animation to running the \"coin\" animation.\n- Coin\n  - has a state machine \"CoinMachine\" which runs an animation of a coin flying up and back down again. \n\nThis animation is setup so that you can draw the background first and layer the Piggy animation ontop of it. \nWhen you want to animate a coin, we add a new coin artboard onto our canvas and animate its coinmachine animation. This artboard will be removed once the animation is played. We also run the \"Pressed\" input for the PiggyMachine, to make the pig interact with the press events a little bit. \n\n# Code \n\nMost of the code, and the animation loop live in [PiggyDrawable](https://github.com/mjtalbot/rive_piggy/blob/main/app/src/main/java/com/test/piggybank/PiggyDrawable.kt), its wrapped up in a [button](https://github.com/mjtalbot/rive_piggy/blob/main/app/src/main/java/com/test/piggybank/RivePiggyButton.kt) class that we use to capture the touch events.\n\n# Same thing, but in JS\n\nLuigi's original [example](https://codesandbox.io/s/piggy-htzfc?file=/src/index.js) of this for the web. There are great comments in the code here to understand how this works for javascript. \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmjtalbot%2Frive_piggy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmjtalbot%2Frive_piggy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmjtalbot%2Frive_piggy/lists"}