{"id":38791520,"url":"https://github.com/joelschutz/stagehand","last_synced_at":"2026-01-17T12:38:44.438Z","repository":{"id":159978273,"uuid":"634867277","full_name":"joelschutz/stagehand","owner":"joelschutz","description":"The only scene manager you will ever need for Ebitengine","archived":false,"fork":false,"pushed_at":"2024-11-05T01:02:58.000Z","size":41,"stargazers_count":26,"open_issues_count":2,"forks_count":5,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-11-05T02:17:30.960Z","etag":null,"topics":["ebitengine","gamedev","go","go-game","tools"],"latest_commit_sha":null,"homepage":"","language":"Go","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/joelschutz.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-05-01T12:16:36.000Z","updated_at":"2024-11-05T01:02:32.000Z","dependencies_parsed_at":"2024-02-25T23:23:29.288Z","dependency_job_id":"498bccdb-dd3b-4b57-b0bf-3016d0665813","html_url":"https://github.com/joelschutz/stagehand","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/joelschutz/stagehand","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joelschutz%2Fstagehand","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joelschutz%2Fstagehand/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joelschutz%2Fstagehand/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joelschutz%2Fstagehand/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/joelschutz","download_url":"https://codeload.github.com/joelschutz/stagehand/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joelschutz%2Fstagehand/sbom","scorecard":{"id":527052,"data":{"date":"2025-08-11","repo":{"name":"github.com/joelschutz/stagehand","commit":"fc7077d47e14b5604f2b1cd72a6e903cc1bb1b44"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.3,"checks":[{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Code-Review","score":2,"reason":"Found 1/4 approved changesets -- score normalized to 2","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/tests.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/joelschutz/stagehand/tests.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/tests.yml:18: update your workflow using https://app.stepsecurity.io/secureworkflow/joelschutz/stagehand/tests.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/tests.yml:32: update your workflow using https://app.stepsecurity.io/secureworkflow/joelschutz/stagehand/tests.yml/master?enable=pin","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   1 third-party GitHubAction dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/tests.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 28 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":7,"reason":"3 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GO-2023-1990 / GHSA-j3p8-6mrq-6g7h","Warn: Project is vulnerable to: GO-2023-1989 / GHSA-x92r-3vfx-4cv3","Warn: Project is vulnerable to: GO-2024-2937 / GHSA-9phm-fm57-rhg8"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-20T04:40:44.408Z","repository_id":159978273,"created_at":"2025-08-20T04:40:44.408Z","updated_at":"2025-08-20T04:40:44.408Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28508488,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-17T11:50:55.898Z","status":"ssl_error","status_checked_at":"2026-01-17T11:50:55.569Z","response_time":85,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: 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":["ebitengine","gamedev","go","go-game","tools"],"created_at":"2026-01-17T12:38:44.349Z","updated_at":"2026-01-17T12:38:44.426Z","avatar_url":"https://github.com/joelschutz.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Stagehand\n\n![Codecov](https://img.shields.io/codecov/c/gh/joelschutz/stagehand?token=3BD1FTRKUC)\n[![issues](https://img.shields.io/github/issues/joelschutz/stagehand)](https://github.com/joelschutz/stagehand/issues)\n![GitHub Release](https://img.shields.io/github/v/release/joelschutz/stagehand)\n[![license](https://img.shields.io/github/license/joelschutz/stagehand)](https://github.com/joelschutz/stagehand/blob/main/LICENSE)\n\nStagehand is a scene manager library for [Ebitengine](https://ebitengine.org) that makes it easy to manage game scenes and state. With Stagehand, you can quickly create and transition between scenes, allowing you to focus on the content and gameplay of your game.\n\n\n## Installation\n\nTo use Stagehand, simply import it into your project:\n\n```\nimport \"github.com/joelschutz/stagehand\"\n```\n\n## Features\n\n- Lightweight and easy-to-use scene management for Ebitengine\n- Simple and flexible API for creating and switching between scenes\n- Managed type-safe states with the power of generics\n- Built-in support for transition effects between scenes\n- Supports custom transition effects by implementing the `SceneTransition` interface\n\n## Usage\n\nTo use Stagehand, you first need to create a struct that implements the `Scene` interface:\n\n```go\ntype MyState struct {\n    // your state data\n}\n\ntype MyScene struct {\n    // your scene fields\n    sm *stagehand.SceneManager[MyState]\n}\n\nfunc (s *MyScene) Update() error {\n    // your update code\n}\n\nfunc (s *MyScene) Draw(screen *ebiten.Image) {\n    // your draw code\n}\n\nfunc (s *MyScene) Load(state MyState ,manager stagehand.SceneController[MyState]) {\n    // your load code\n    s.sm = manager.(*stagehand.SceneManager[MyState]) // This type assertion is important\n}\n\nfunc (s *MyScene) Unload() MyState {\n    // your unload code\n}\n```\n\nThen, create an instance of the `SceneManager` passing initial scene and state.\n\n```go\nfunc main() {\n    // ...\n    scene1 := \u0026MyScene{}\n    state := MyState{}\n    manager := stagehand.NewSceneManager[MyState](scene1, state)\n\n    if err := ebiten.RunGame(sm); err != nil {\n        log.Fatal(err)\n    }\n}\n```\n\n### Examples\n\nWe provide some example code so you can start fast:\n\n- [Simple Example](https://github.com/joelschutz/stagehand/blob/master/examples/simple/main.go)\n- [Timed Transition Example](https://github.com/joelschutz/stagehand/blob/master/examples/timed/main.go)\n- [Transition Awareness Example](https://github.com/joelschutz/stagehand/blob/master/examples/aware/main.go)\n- [Scene Director Example](https://github.com/joelschutz/stagehand/blob/master/examples/director/main.go)\n\n## Transitions\n\nYou can switch scenes by calling `SwitchTo` method on the `SceneManager` giving the scene instance you wanna switch to.\n\n```go\nfunc (s *MyScene) Update() error {\n    // ...\n    scene2 := \u0026OtherScene{}\n    s.manager.SwitchTo(scene2)\n\n    // ...\n}\n```\n\nYou can use the `SwitchWithTransition` method to switch between scenes with a transition effect. Stagehand provides two built-in transition effects: `FadeTransition` and `SlideTransition`.\n\n### Fade Transition\n\nThe `FadeTransition` will fade out the current scene while fading in the new scene.\n\n```go\nfunc (s *MyScene) Update() error {\n    // ...\n    scene2 := \u0026OtherScene{}\n    s.manager.SwitchWithTransition(scene2, stagehand.NewFadeTransition(.05))\n\n    // ...\n}\n```\n\nIn this example, the `FadeTransition` will fade 5% every frame. There is also the option for a timed transition using `NewTicksTimedFadeTransition`(for a ticks based timming) or `NewDurationTimedFadeTransition`(for a real-time based timming).\n\n### Slide Transition\n\nThe `SlideTransition` will slide out the current scene and slide in the new scene.\n\n```go\nfunc (s *MyScene) Update() error {\n    // ...\n    scene2 := \u0026OtherScene{}\n    s.manager.SwitchWithTransition(scene2, stagehand.NewSlideTransition(stagehand.LeftToRight, .05))\n\n    // ...\n}\n```\n\nIn this example, the `SlideTransition` will slide in the new scene from the left 5% every frame. There is also the option for a timed transition using `NewTicksTimedSlideTransition`(for a ticks based timming) or `NewDurationTimedSlideTransition`(for a real-time based timming).\n\n### Custom Transitions\n\nYou can also define your own transition, simply implement the `SceneTransition` interface, we provide a helper `BaseTransition` that you can use like this:\n\n```go\ntype MyTransition struct {\n    stagehand.BaseTransition\n    progress float64 // An example factor\n}\n\nfunc (t *MyTransition) Start(from, to stagehand.Scene[MyState], sm *SceneManager[MyState]) {\n    // Start the transition from the \"from\" scene to the \"to\" scene here\n    t.BaseTransition.Start(fromScene, toScene, sm)\n    t.progress = 0\n}\n\nfunc (t *MyTransition) Update() error {\n    // Update the progress of the transition\n    t.progress += 0.01\n    return t.BaseTransition.Update()\n}\n\nfunc (t *MyTransition) Draw(screen *ebiten.Image) {\n    // Optionally you can use a helper function to render each scene frame\n    toImg, fromImg := stagehand.PreDraw(screen.Bounds(), t.fromScene, t.toScene)\n\n    // Draw transition effect here\n}\n\n```\n\n### Transition Awareness\n\nWhen a scene is transitioned, the `Load` and `Unload` methods are called **twice** for the destination and original scenes respectively. Once at the start and again at the end of the transition. This behavior can be changed for additional control by implementing the `TransitionAwareScene` interface.\n\n```go\nfunc (s *MyScene) PreTransition(destination Scene[MyState]) MyState  {\n    // Runs before new scene is loaded\n}\n\nfunc (s *MyScene) PostTransition(lastState MyState, original Scene[MyState]) {\n    // Runs when old scene is unloaded\n}\n```\n\nWith this you can insure that those methods are only called once on transitions and can control your scenes at each point of the transition. The execution order will be:\n\n```shell\nPreTransition Called on old scene\nLoad Called on new scene\nUpdated old scene\nUpdated new scene\n...\nUpdated old scene\nUpdated new scene\nUnload Called on old scene\nPostTransition Called on new scene\n```\n\n## SceneDirector\n\nThe `SceneDirector` is an alternative way to manage the transitions between scenes. It provides transitioning between scenes based on a set of rules just like a FSM. The `Scene` implementation is the same, with only a feel differences, first you need to assert the `SceneDirector` instead of the `SceneManager`:\n\n```go\ntype MyScene struct {\n    // your scene fields\n    director *stagehand.SceneDirector[MyState]\n}\n\nfunc (s *MyScene) Load(state MyState ,director stagehand.SceneController[MyState]) {\n    // your load code\n    s.director = director.(*stagehand.SceneDirector[MyState]) // This type assertion is important\n}\n```\n\nThen define a ruleSet of `Directive` and `SceneTransitionTrigger` for the game.\n\n```go\n// Triggers are int type underneath\nconst (\n\tTrigger1 stagehand.SceneTransitionTrigger = iota\n    Trigger2\n)\n\nfunc main() {\n    // ...\n    scene1 := \u0026MyScene{}\n    scene2 := \u0026OtherScene{}\n\n    // Create a rule set for transitioning between scenes based on Triggers\n    ruleSet := make(map[stagehand.Scene[MyState]][]Directive[MyState])\n    directive1 := Directive[MyState]{Dest: scene2, Trigger: Trigger1}\n    directive2 := Directive[MyState]{Dest: scene1, Trigger: Trigger2, Transition: stagehand.NewFadeTransition(.05)} // Add transitions inside the directive\n\n    // Directives are mapped to each Scene pointer and can be shared\n    ruleSet[scene1] = []Directive[MyState]{directive1, directive2}\n    ruleSet[scene2] = []Directive[MyState]{directive2}\n\n    state := MyState{}\n    manager := stagehand.NewSceneDirector[MyState](scene1, state, ruleSet)\n\n    if err := ebiten.RunGame(sm); err != nil {\n        log.Fatal(err)\n    }\n}\n```\n\nNow you can now notify the `SceneDirector` about activated `SceneTransitionTrigger`, if no `Directive` match, the code will still run without errors.\n\n```go\nfunc (s *MyScene) Update() error {\n    // ...\n\ts.manager.ProcessTrigger(Trigger)\n\n    // ...\n}\n```\n\n## Acknowledgments\n\n- When switching scenes (i.e. calling `SwitchTo`, `SwitchWithTransition` or `ProcessTrigger`) while a transition is running it will immediately be canceled and the new switch will be started. To prevent this behavior use a TransitionAwareScene and prevent this methods to be called.\n\n## Contribution\n\nContributions are welcome! If you find a bug or have a feature request, please open an issue on GitHub. If you would like to contribute code, please fork the repository and submit a pull request.\n\nBefore submitting a pull request, please make sure to run the tests:\n\n```\ngo test ./...\n```\n\n## License\n\nStagehand is released under the [MIT License](https://github.com/joelschutz/stagehand/blob/master/LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoelschutz%2Fstagehand","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoelschutz%2Fstagehand","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoelschutz%2Fstagehand/lists"}