Source Academy Modules
    Preparing search index...

    Function update_loop

    • This sets the update loop in the canvas. The update loop is run once per frame, so it depends on the fps set for the number of times this loop is run. There should only be one update_loop called. All game logic should be handled within your update_function. You cannot create GameObjects inside the update_loop. game_state is an array that can be modified to store anything.

      Parameters

      • update_function: UpdateFunction

        A user-defined update_function, that takes in an array as a parameter.

      Returns void

      // Create gameobjects outside update_loop
      update_loop((game_state) => {
      // Update gameobjects inside update_loop

      // Using game_state as a counter
      if (game_state[0] === undefined) {
      game_state[0] = 0;
      }
      game_state[0] = game_state[0] + 1;
      });