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: [#242] Implement Parallel Actions #2322

Merged
merged 8 commits into from
May 27, 2022
Merged

Conversation

eonarheim
Copy link
Member

@eonarheim eonarheim commented May 23, 2022

===: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)

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

Closes #242

This PR implements 2 new Action types to enable running parallel actions. ActionSequence which allows developers to specify a sequence of actions to run in order, and ParallelActions to run multiple actions at the same time.

parallel-actions3

Example, moves the actor in a box while rotating it at the same time

var sequence1 = new ex.ActionSequence(actor, ctx => {
  ctx.easeBy(ex.vec(200, 0), 1000, ex.EasingFunctions.EaseInOutCubic);
  ctx.delay(500);
  ctx.easeBy(ex.vec(0, 200), 1000, ex.EasingFunctions.EaseInOutCubic);
  ctx.delay(500);
  ctx.easeBy(ex.vec(-200, 0), 1000, ex.EasingFunctions.EaseInOutCubic);
  ctx.delay(500);
  ctx.easeBy(ex.vec(0, -200), 1000, ex.EasingFunctions.EaseInOutCubic);
  ctx.delay(500);
});

var sequence2 = new ex.ActionSequence(actor, ctx => {
  ctx.rotateBy(Math.PI, Math.PI, ex.RotationType.Clockwise);
  ctx.delay(500);
  ctx.rotateBy(Math.PI, Math.PI, ex.RotationType.CounterClockwise);
  ctx.delay(500);
  ctx.rotateBy(Math.PI, Math.PI, ex.RotationType.Clockwise);
  ctx.delay(500);
  ctx.rotateBy(Math.PI, Math.PI, ex.RotationType.CounterClockwise);
  ctx.delay(500);
});

var parallel = new ex.ParallelActions([sequence1, sequence2]);

actor.actions.repeatForever(ctx => ctx.runAction(parallel));

Changes:

  • Fix some bugs in existing action types
  • Add the missing EaseBy action type
  • Add new ActionSequence action type
  • Add new ParallelActions action type

@github-actions github-actions bot added the enhancement Label applied to enhancements or improvements to existing features label May 23, 2022
@eonarheim eonarheim merged commit eead083 into main May 27, 2022
@eonarheim eonarheim deleted the feature/parallel-actions branch May 27, 2022 13: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.

investigate parallel actions
1 participant