Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Scene input API #2889

Merged
merged 9 commits into from
Jan 29, 2024
Merged

feat: Scene input API #2889

merged 9 commits into from
Jan 29, 2024

Conversation

eonarheim
Copy link
Member

@eonarheim eonarheim commented Jan 16, 2024

===:clipboard: PR Checklist :clipboard:===

  • 📌 issue exists in github for these changes
  • 🔬 existing tests still pass
  • 🙈 code conforms to the style guide
  • 📐 new tests written and passing / old tests updated with new scenario(s)
  • 📄 changelog entry added (or not needed)

==================

This PR enables scene specific input APIs that only fire handlers when the scene is active! This is very useful if you have a lot of handlers to manage and don't want to keep track of engine level subscriptions.

class SceneWithInput extends ex.Scene {
  onInitialize(engine: ex.Engine<any>): void {
    this.input.pointers.on('down', () => {
      console.log('pointer down from scene1');
    });
  }
}
class OtherSceneWithInput extends ex.Scene {
  onInitialize(engine: ex.Engine<any>): void {
    this.input.pointers.on('down', () => {
      console.log('pointer down from scene2');
    });
  }
}
scene-input.mp4

@github-actions github-actions bot added the enhancement Label applied to enhancements or improvements to existing features label Jan 16, 2024
@eonarheim eonarheim merged commit e397cbb into main Jan 29, 2024
4 of 5 checks passed
@eonarheim eonarheim deleted the feat/scene-specific-input branch January 29, 2024 17:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Label applied to enhancements or improvements to existing features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant