mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-23 14:32:59 -05:00
Merge pull request #1122 from Kenny2github/develop
Handle random backdrop menu option
This commit is contained in:
commit
cf8ad388de
1 changed files with 7 additions and 0 deletions
|
@ -343,6 +343,13 @@ class Scratch3LooksBlocks {
|
||||||
} else if (requestedCostume === 'next costume' ||
|
} else if (requestedCostume === 'next costume' ||
|
||||||
requestedCostume === 'next backdrop') {
|
requestedCostume === 'next backdrop') {
|
||||||
target.setCostume(target.currentCostume + 1);
|
target.setCostume(target.currentCostume + 1);
|
||||||
|
} else if (requestedCostume === 'random backdrop') {
|
||||||
|
const numCostumes = target.getCostumes().length;
|
||||||
|
if (numCostumes > 1) {
|
||||||
|
let selectedIndex = Math.floor(Math.random() * (numCostumes - 1));
|
||||||
|
if (selectedIndex === target.currentCostume) selectedIndex += 1;
|
||||||
|
target.setCostume(selectedIndex);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
const forcedNumber = Number(requestedCostume);
|
const forcedNumber = Number(requestedCostume);
|
||||||
if (!isNaN(forcedNumber)) {
|
if (!isNaN(forcedNumber)) {
|
||||||
|
|
Loading…
Reference in a new issue