Open spustlik opened 5 months ago
Hi @spustlik, I agree the current parallel actions is a bit clunky to use. I definitely think there is a better api here. Your proposal is interesting I'd like to play with it more 👍
myactor.actions
.paralel(ctx=>[
ctx.moveTo(...),
ctx.scaleTo(...),
]);
In the near term coroutines are a nice way to do more complicated animation simultaneously https://excaliburjs.com/docs/coroutines/
Here is an example doing some scaling on different axes at the same time
var newScaleBy = (actor: ex.Actor, scaleChange: ex.Vector, durationSeconds: number) => {
// coroutines start automatically
ex.coroutine(function* () {
let duration = durationSeconds * 1000; // milliseconds
let xScaleChangeRate = scaleChange.x / duration;
let yScaleChangeRate = scaleChange.y / duration;
let targetScale = actor.scale.add(scaleChange);
while (duration > 0) {
const elapsed = yield;
duration -= elapsed;
actor.scale.x += xScaleChangeRate * elapsed;
actor.scale.y += yScaleChangeRate * elapsed;
}
actor.scale = targetScale;
});
};
actor.onInitialize = () => {
newScaleBy(actor, ex.vec(-0.5, -0.25), 2);
};
This issue hasn't had any recent activity lately and is being marked as stale automatically.
Context
using paralel actions is different than using standard actions
Proposal
please consider to add new method to
ActionContext
probably.parallel()
with inner context parameter like.repeat()
, where it will be possible to use fluent Action API something likemaybe it is possible to use generators with yield.
also usable should be shortcut for
to