Add one to index if random costume is current costume

This commit is contained in:
Kenny2github 2018-05-09 08:13:04 +08:00
parent 3f1c4aa2d8
commit 8e9f9e0a30

View file

@ -346,11 +346,9 @@ class Scratch3LooksBlocks {
} else if (requestedCostume === 'random backdrop') {
const numCostumes = target.getCostumes().length;
if (numCostumes > 1) {
let index;
do {
index = Math.floor(Math.random() * numCostumes);
} while (index === target.currentCostume);
target.setCostume(index);
let selectedIndex = Math.floor(Math.random() * (numCostumes - 1));
if (selectedIndex === target.currentCostume) selectedIndex += 1;
target.setCostume(selectedIndex);
}
} else {
const forcedNumber = Number(requestedCostume);