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: Collision lifecycle convenience methods on Actor #2869

Merged
merged 2 commits into from
Jan 6, 2024

Conversation

eonarheim
Copy link
Member

@eonarheim eonarheim commented Jan 6, 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 adds new collision lifecycle convenience methods to Actor! This was possible before by wiring up an event handler. This is a super common pattern so now it's moved to Actor!

class MyActor extends ex.Actor {
  constructor(args: ex.ActorArgs) {
    super(args);
  }
  onPreCollisionResolve(self: ex.Collider, other: ex.Collider, side: ex.Side, contact: ex.CollisionContact): void {
    
  }
  onPostCollisionResolve(self: ex.Collider, other: ex.Collider, side: ex.Side, contact: ex.CollisionContact): void {
    
  }
  onCollisionStart(self: ex.Collider, other: ex.Collider, side: ex.Side, contact: ex.CollisionContact): void {
    
  }
  onCollisionEnd(self: ex.Collider, other: ex.Collider): void {
    
  }
}

@github-actions github-actions bot added the enhancement Label applied to enhancements or improvements to existing features label Jan 6, 2024
@eonarheim eonarheim merged commit fa5c10f into main Jan 6, 2024
6 checks passed
@eonarheim eonarheim deleted the feat/collision-lifecycles branch January 6, 2024 00:39
console.log('other collision start')
}
onCollisionEnd(self: ex.Collider, other: ex.Collider): void {
console.log('other collision start')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably meant other collision end

}

/**
* Fires every after collision resolution for a confirmed contact.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing word, probably frame, after Fires every

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yup, should read "fires for every collision resolution for a confirmed contact"

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.

2 participants