Skip to content

Deduplicate group lookup, all group blocks should accept "rand" as an option #565

Description

@joshlory

These two methods do basically the same:

dance-party/src/p5.dance.js

Lines 563 to 581 in f0c34bc

changeMoveEachLR(group, move, dir) {
group = this.getGroupByName_(group);
if ((move === "rand") && (group.length>0)) {
move = this.getNewChangedMove(move, group[0].current_move, false);
}
group.forEach(sprite => {
this.changeMoveLR(sprite, move, dir);
});
}
doMoveEachLR(group, move, dir) {
group = this.getGroupByName_(group);
if ((move === "rand") && (group.length>0)) {
move = this.getNewChangedMove(move, group[0].current_move, true);
}
group.forEach(sprite => {
this.doMoveLR(sprite, move, dir);
});
}

So does this method, but it doesn't account for the "rand" case:

dance-party/src/p5.dance.js

Lines 851 to 856 in f0c34bc

setPropEach(group, property, val) {
group = this.getGroupByName_(group);
group.forEach(function (sprite){
this.setProp(sprite, property, val);
}, this);
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions