Class: Screen

plugins/screens. Screen

When any ScreenArranger is used, an instance of this class will be added to every player. Here you can find all information and helper methods relevant for positioning one screen on a bigger playing field.

new Screen(player)

Parameters:
Name Type Description
player module:shared/player~Player player instance this screen is added to
Source:

Members

bottomPlayers :Array

list of all player instances that border on the bottom of this screen
Type:
  • Array
Source:

height :integer

height of the screen in pixel
Type:
  • integer
Source:

leftPlayers :Array

list of all player instances that border on the left side of this screen
Type:
  • Array
Source:

player :module:shared/player~Player

player instance this screen is added to
Type:
Source:

rightPlayers :Array

list of all player instances that border on the right side of this screen
Type:
  • Array
Source:

topPlayers :Array

list of all player instances that border on the top of this screen
Type:
  • Array
Source:

width :integer

width of the screen in pixel
Type:
  • integer
Source:

x :integer

global x-position (from left) of this screen in pixel
Type:
  • integer
Source:

y :integer

global x-position (from top) of this screen in pixel
Type:
  • integer
Source:

Methods

globalToLocal(x, y) → {object}

Converts global pixel coordinates to local ones, using this screen as local coordinate system.
Parameters:
Name Type Description
x integer global x position in pixel
y integer global y position in pixel
Source:
Returns:
{ x: localX, y: localY, player: this.player }
Type
object

isHitByRect(x, y, width, height) → {boolean}

Parameters:
Name Type Description
x integer global x-coordinate of the upper left corner of the rectangle in pixel
y integer global y-coordinate of the upper left corner of the rectangle in pixel
width integer width of the rectangle in pixel
height integer height of the rectangle in pixel
Source:
Returns:
true if the given rectangle or parts of it overlap with this screen
Type
boolean

localToGlobal(x, y) → {object}

Converts local pixel coordinates to global ones, using this screen as local coordinate system.
Parameters:
Name Type Description
x integer local x position in pixel
y integer local y position in pixel
Source:
Returns:
{ x: globalX, y: globalY }
Type
object