Language

Player.getScreen


Player.getScreen() : array(2)

Description

Return an array containing the X and Y coordinate of the screen the player is currently in. Refer to the image below for the screen coordinates.

Return

Return an array with the X and Y coordinate of the screen region. See examples.


Examples

Only update what is in current screen region

This example shows you how to run code depending on which screen region the player actually in.

  1. function onUpdate(elapsed)
  2.     local screen = Player.getScreen()
  3.    
  4.     if screen[1] == 1 and screen[2] == 1 then
  5.         -- Do stuff when player is in the top-left first screen
  6.     end
  7.     if screen[1] == 1 and screen[2] == 2 then
  8.         -- Do stuff when player is below the first screen
  9.     end
  10. end