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: Implement SpriteSheet getSprite options #2901

Merged
merged 3 commits into from
Jan 23, 2024

Conversation

eonarheim
Copy link
Member

@eonarheim eonarheim commented Jan 23, 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 implements new ex.SpriteSheet.getSprite(..., options)

You can now influence sprites directly out of the sprite sheet

const sprite = ss.getSprite(0, 0, {
  flipHorizontal: true,
  flipVertical: true,
  width: 200,
  height: 201,
  opacity: .5,
  scale: ex.vec(2, 2),
  origin: ex.vec(0, 1),
  tint: ex.Color.Red,
  rotation: 4
});

Also the animation helper ex.Animation.fromSpriteSheetCoordinates() you can now pass any valid ex.GraphicOptions to influence the sprite per frame

const anim = ex.Animation.fromSpriteSheetCoordinates({
  spriteSheet: ss,
  frameCoordinates: [
    {x: 0, y: 0, duration: 100, options: { flipHorizontal: true }},
    {x: 1, y: 0, duration: 100, options: { flipVertical: true }},
    {x: 2, y: 0, duration: 100},
    {x: 3, y: 0, duration: 100}
  ],
  strategy: ex.AnimationStrategy.Freeze
});

@github-actions github-actions bot added the enhancement Label applied to enhancements or improvements to existing features label Jan 23, 2024
@eonarheim eonarheim changed the title feat: Implement sprite sheet getSprite options feat: Implement SpriteSheet getSprite options Jan 23, 2024
@eonarheim eonarheim merged commit 73d94d8 into main Jan 23, 2024
4 of 5 checks passed
@eonarheim eonarheim deleted the feat/spritesheet-getsprite-options branch January 23, 2024 01:39
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