Skip to content

Commit

Permalink
Start triggers in top-down order
Browse files Browse the repository at this point in the history
This matches how Scratch does it.
  • Loading branch information
adroitwhiz committed Jul 16, 2024
1 parent 665885a commit 8791286
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,9 @@ export default class Project {
triggerMatches: (tr: Trigger, target: Sprite | Stage) => boolean
): TriggerWithTarget[] {
const matchingTriggers: TriggerWithTarget[] = [];
for (const target of this.targets) {
// Iterate over targets in top-down order, as Scratch does
for (let i = this.targets.length - 1; i >= 0; i--) {
const target = this.targets[i];
const matchingTargetTriggers = target.triggers.filter((tr) =>
triggerMatches(tr, target)
);
Expand Down

0 comments on commit 8791286

Please sign in to comment.