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

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

Open
joshlory opened this issue Sep 13, 2019 · 0 comments

Comments

@joshlory
Copy link
Contributor

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);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant