Screen
Index
Constructors
Properties
Accessors
- antialiasing
- aspectRatio
- canvas
- canvasHeight
- canvasWidth
- center
- contentArea
- displayMode
- drawHeight
- drawWidth
- halfCanvasHeight
- halfCanvasWidth
- halfDrawHeight
- halfDrawWidth
- height
- isFullScreen
- isFullscreen
- isHiDpi
- parent
- pixelRatio
- pixelRatioOverride
- resolution
- scaledHeight
- scaledWidth
- unsafeArea
- viewport
- width
- worldToPagePixelRatio
Methods
- applyResolutionAndViewport
- dispose
- enterFullscreen
- exitFullScreen
- 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
Get or set screen antialiasing,
If true smoothing is applied
Returns boolean
Get or set screen antialiasing
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
publicheight
Returns number
publicisFullScreen
Returns true if excalibur is fullscreen using the browser fullscreen api
Returns boolean
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 Resolution
Parameters
resolution: Resolution
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 ViewportDimension
Parameters
viewport: ViewportDimension
Returns void
publicwidth
Returns the width of the engine's visible drawing surface in pixels including zoom and device pixel ratio.
Returns number
publicworldToPagePixelRatio
This calculates the ratio between excalibur pixels and the HTML pixels.
This is useful for scaling HTML UI so that it matches your game.
Returns number
Methods
publicapplyResolutionAndViewport
Returns void
publicdispose
Returns void
publicenterFullscreen
Requests to enter 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>
publicexitFullScreen
Requests to exit fullscreen using the browser fullscreen api
Returns Promise<void>
publicexitFullscreen
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 Resolution
publicpeekViewport
Returns ViewportDimension
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
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
publicworldToPageCoordinates
publicworldToScreenCoordinates
Takes a coordinate in Excalibur world space, and translates it to Excalibur screen space.
Screen space is where
screen elements
andentities
with CoordPlane.Screen live.Parameters
point: Vector
World coordinate to convert
Returns Vector
The Screen handles all aspects of interacting with the screen for Excalibur.