Screen
Index
Constructors
Properties
Accessors
Methods
- applyResolutionAndViewport
- dispose
- exitFullScreen
- getScreenBounds
- getWorldBounds
- goFullScreen
- pageToScreenCoordinates
- pageToWorldCoordinates
- peekResolution
- peekViewport
- popResolutionAndViewport
- pushResolutionAndViewport
- screenToPageCoordinates
- screenToWorldCoordinates
- setCurrentCamera
- worldToPageCoordinates
- worldToScreenCoordinates
Constructors
constructor
Parameters
options: ScreenOptions
Returns Screen
Properties
publicevents
Listen to screen events [[ScreenEvents]]
publicgraphicsContext
Accessors
publicantialiasing
Returns boolean
Parameters
isSmooth: boolean
Returns void
publicaspectRatio
Returns number
publiccanvas
Returns HTMLCanvasElement
publiccanvasHeight
The height of the game canvas in pixels, (physical height component of the resolution of the canvas element)
Returns number
publiccanvasWidth
The width of the game canvas in pixels (physical width component of the resolution of the canvas element)
Returns number
publiccenter
Returns screen center coordinates including zoom and device pixel ratio.
Returns Vector
publiccontentArea
Returns the content area in screen space where it is safe to place content
Returns BoundingBox
publicdisplayMode
Returns DisplayMode
publicdrawHeight
Returns the height of the engine's visible drawing surface in pixels including zoom and device pixel ratio.
Returns number
publicdrawWidth
Returns the width of the engine's visible drawing surface in pixels including zoom and device pixel ratio.
Returns number
publichalfCanvasHeight
Returns half height of the game canvas in pixels (half physical height component)
Returns number
publichalfCanvasWidth
Returns half width of the game canvas in pixels (half physical width component)
Returns number
publichalfDrawHeight
Returns half the height of the engine's visible drawing surface in pixels including zoom and device pixel ratio.
Returns number
publichalfDrawWidth
Returns half the width of the engine's visible drawing surface in pixels including zoom and device pixel ratio.
Returns number
publicisFullScreen
Returns true if excalibur is fullscreen using the browser fullscreen api
Returns boolean
publicisHiDpi
Returns boolean
publicparent
Returns HTMLElement | Window
publicpixelRatio
Returns the computed pixel ratio, first using any override, then the device pixel ratio
Returns number
publicpixelRatioOverride
Get or set the pixel ratio override
You will need to call applyResolutionAndViewport() affect change on the screen
Returns number
Parameters
value: number
Returns void
publicresolution
Returns ScreenDimension
Parameters
resolution: ScreenDimension
Returns void
publicscaledHeight
Returns number
publicscaledWidth
Returns number
publicunsafeArea
Returns the unsafe area in screen space, this is the full screen and some space may not be onscreen.
Returns BoundingBox
publicviewport
Returns screen dimensions in pixels or percentage
Returns ScreenDimension
Parameters
viewport: ScreenDimension
Returns void
Methods
publicapplyResolutionAndViewport
Returns void
publicdispose
Returns void
publicexitFullScreen
Requests to exit fullscreen using the browser fullscreen api
Returns Promise<void>
publicgetScreenBounds
Returns a BoundingBox of the top left corner of the screen and the bottom right corner of the screen.
Screen bounds are in screen coordinates, useful for culling objects offscreen that are in screen space
Returns BoundingBox
publicgetWorldBounds
Returns a BoundingBox of the top left corner of the screen and the bottom right corner of the screen.
World bounds are in world coordinates, useful for culling objects offscreen that are in world space
Returns BoundingBox
publicgoFullScreen
Requests to go fullscreen using the browser fullscreen api, requires user interaction to be successful. For example, wire this to a user click handler.
Optionally specify a target element id to go fullscreen, by default the game canvas is used
Parameters
optionalelementId: string
Returns Promise<void>
publicpageToScreenCoordinates
Takes a coordinate in normal html page space, for example from a pointer move event, and translates it to Excalibur screen space.
Excalibur screen space starts at the top left (0, 0) corner of the viewport, and extends to the bottom right corner (resolutionX, resolutionY). When using *AndFill suffixed display modes screen space (0, 0) is the top left of the safe content area bounding box not the viewport.
Parameters
point: Vector
Returns Vector
publicpageToWorldCoordinates
publicpeekResolution
Returns ScreenDimension
publicpeekViewport
Returns ScreenDimension
publicpopResolutionAndViewport
Returns void
publicpushResolutionAndViewport
Returns void
publicscreenToPageCoordinates
Takes a coordinate in Excalibur screen space, and translates it to normal html page space. For example, this is where html elements might live if you want to position them relative to Excalibur.
Excalibur screen space starts at the top left (0, 0) corner of the viewport, and extends to the bottom right corner (resolutionX, resolutionY)
Parameters
point: Vector
Returns Vector
publicscreenToWorldCoordinates
Takes a coordinate in Excalibur screen space, and translates it to Excalibur world space.
World space is where [[Entity|entities]] in Excalibur live by default [[CoordPlane.World]] and extends infinitely out relative from the [[Camera]].
Parameters
point: Vector
Screen coordinate to convert
Returns Vector
publicsetCurrentCamera
Parameters
camera: Camera
Returns void
The Screen handles all aspects of interacting with the screen for Excalibur.