-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
can create a menu that pauses the gameplay
- Loading branch information
Showing
2 changed files
with
41 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
|
||
namespace miniMenu{ | ||
|
||
|
||
function createMenuAndPauseGame(items: miniMenu.MenuItem[]): miniMenu.MenuSprite{ | ||
let img = image.screenImage().clone(); | ||
game.pushScene(); | ||
scene.setBackgroundImage(img) | ||
let myMenu = miniMenu.createMenuFromArray(items); | ||
myMenu.onButtonPressed(controller.A, function (selection: string, selectedIndex: number) { | ||
myMenu.close(); | ||
game.popScene(); | ||
}) | ||
return myMenu | ||
} | ||
|
||
/** | ||
* Creates and returns a menu from an array of menu items passed in. Can toggle if the game is paused or not | ||
*/ | ||
//% blockId=createPauseableMenu | ||
//% block="create menu from $items where pause is $isPaused" | ||
//% blockSetVariable=myMenu | ||
//% items.shadow=lists_create_with | ||
//% items.defl=mini_menu_create_menu_item | ||
//% group="Create" | ||
//% weight=99 | ||
|
||
export function createPauseableMenu(isPaused: boolean, items: miniMenu.MenuItem[]): miniMenu.MenuSprite{ | ||
let myMenu: miniMenu.MenuSprite; | ||
if (isPaused){ | ||
myMenu = createMenuAndPauseGame(items); | ||
} | ||
else{ | ||
myMenu = createMenuFromArray(items); | ||
} | ||
return myMenu | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters