mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-23 06:23:37 -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' ||
|
||||
requestedCostume === 'next backdrop') {
|
||||
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 {
|
||||
const forcedNumber = Number(requestedCostume);
|
||||
if (!isNaN(forcedNumber)) {
|
||||
|
|
Loading…
Reference in a new issue