• Hi

    Below you can find some example code to illustrate my problem.

    When I select "Start a game" in the menu, I start my game. But when I press BTN1 "in the game", the menu keeps flashing and when I press BTN1 / BTN2, the menu items are selected again and the game function for these buttons are activated too.

    So how can I stop the built in button watches of the E.showMenu() function? Or what am I doing wrong?

    Greets

    Stijn

    // Game functions
    function startGame () {
      g.clear();
      g.setColor("#ffffff");
      g.drawString("game started", 50, 100);
      
      setWatch(function() { 
        g.clear();
        g.setColor("#ffffff");
        g.drawString("btn 1 pressed", 50, 110); 
        console.log("btn 1 pressed");
      }, BTN1, {repeat: true});
      
      setWatch(function() { 
        g.clear();
        g.setColor("#ffffff");
        g.drawString("btn 2 pressed", 50, 120); 
        console.log("btn 2 pressed");
      }, BTN2, {repeat: true});
    }
    
    // Global functions
    function closeApp() {
      console.log("App closed");
      load();
    }
    
    // --- Menu
    var mainMenu = {
      "": { "title": "Menu" },
      "Start a game": () => startGame(),
      "Exit" : () => closeApp(),
    };
    
    function onInit(){
      E.showMenu(mainMenu);
    }
    
    // --- Initialize app
    onInit();
    
About

Avatar for skelesp @skelesp started