Class: Viewport

me. Viewport

new Viewport(minX, minY, maxX, maxY)

a camera/viewport Object
Parameters:
Name Type Description
minX Number start x offset
minY Number start y offset
maxX Number end x offset
maxY Number end y offset
Source:
viewport.js, line 23

Extends

Members

<static> AXIS :Number

Axis definition
Type:
  • Number
Properties:
Name Type Description
NONE
HORIZONTAL
VERTICAL
BOTH
Source:
viewport.js, line 29

<static, constant> bounds :me.Rect

Camera bounds
Type:
Source:
viewport.js, line 48

alpha :Number

Define the renderable opacity
Set to zero if you do not wish an object to be drawn
Type:
  • Number
Inherited From:
Default Value:
  • 1.0
Source:
renderable.js, line 151
See:
  • me.Renderable#setOpacity
  • me.Renderable#getOpacity

ancestor :me.Container

a reference to the Container object that contains this renderable, or undefined if it has not been added to one.
Type:
Inherited From:
Default Value:
  • undefined
Source:
renderable.js, line 163

Methods

<static> fadeIn(color, duration, onComplete)

fadeIn effect

fade to the specified color

Parameters:
Name Type Argument Default Description
color me.Color | String a CSS color value
duration Number <optional>
1000 expressed in milliseconds
onComplete function <optional>
callback once effect is over
Source:
viewport.js, line 394

<static> fadeOut(color, duration, onComplete)

fadeOut(flash) effect

screen is filled with the specified color and slowly goes back to normal

Parameters:
Name Type Argument Default Description
color me.Color | String a CSS color value
duration Number <optional>
1000 expressed in milliseconds
onComplete function <optional>
callback once effect is over
Source:
viewport.js, line 375

<static> focusOn()

set the viewport position around the specified object
Parameters:
Type Description
me.Renderable
Source:
viewport.js, line 437

<static> follow(target, axis)

set the viewport to follow the specified renderable.
(this will put the viewport center around the given target)
Parameters:
Name Type Argument Default Description
target me.Renderable | me.Vector2d renderable or position Vector to follow
axis me.Viewport.AXIS <optional>
this.AXIS.BOTH Which axis to follow
Source:
viewport.js, line 212

<static> getHeight() → {Number}

return the viewport height
Source:
viewport.js, line 426
Returns:
Type
Number

<static> getWidth() → {Number}

return the viewport width
Source:
viewport.js, line 415
Returns:
Type
Number

<static> isVisible(rect) → {Boolean}

check if the specified rectangle is in the viewport
Parameters:
Name Type Description
rect me.Rect
Source:
viewport.js, line 452
Returns:
Type
Boolean

<static> localToWorld(x, y, v) → {me.Vector2d}

convert the given "local" (screen) coordinates into world coordinates
Parameters:
Name Type Argument Description
x Number
y Number
v Number <optional>
an optional vector object where to set the converted value
Source:
viewport.js, line 464
Returns:
Type
me.Vector2d

<static> move(x, y)

move the viewport upper-left position by the specified offset.
Parameters:
Name Type Description
x Number
y Number
Source:
viewport.js, line 240
See:
Example
// Move the viewport up by four pixels
me.game.viewport.move(0, -4);

<static> moveTo(x, y)

move the viewport upper-left position to the specified coordinates
Parameters:
Name Type Description
x Number
y Number
Source:
viewport.js, line 256
See:

<static> reset(x, y)

reset the viewport to specified coordinates
Parameters:
Name Type Argument Default Description
x Number <optional>
0
y Number <optional>
0
Source:
viewport.js, line 118

<static> resize(w, h) → {me.Viewport}

resize the viewport
Parameters:
Name Type Description
w Number new width of the viewport
h Number new height of the viewport
Source:
viewport.js, line 169
Returns:
this viewport
Type
me.Viewport

<static> setBounds(x, y, w, h)

set the viewport boundaries (set to the world limit by default). the viewport is bound to the given coordinates and cannot move/be scrolled outside of it.
Parameters:
Name Type Description
x Number world left limit
y Number world top limit
w Number world width limit
h Number world height limit
Source:
viewport.js, line 195

<static> setDeadzone(w, h)

change the deadzone settings. the "deadzone" defines an area within the current viewport in which the followed renderable can move without scrolling the viewport.
Parameters:
Name Type Description
w Number deadzone width
h Number deadzone height
Source:
viewport.js, line 141
See:

<static> shake(intensity, duration, axis, onComplete, force)

shake the camera
Parameters:
Name Type Argument Default Description
intensity Number maximum offset that the screen can be moved while shaking
duration Number expressed in milliseconds
axis me.Viewport.AXIS <optional>
this.AXIS.BOTH specify on which axis you want the shake effect
onComplete function <optional>
callback once shaking effect is over
force Boolean <optional>
if true this will override the current effect
Source:
viewport.js, line 350
Example
// shake it baby !
me.game.viewport.shake(10, 500, me.game.viewport.AXIS.BOTH);

<static> worldToLocal(x, y, v) → {me.Vector2d}

convert the given world coordinates into "local" (screen) coordinates
Parameters:
Name Type Argument Description
x Number
y Number
v Number <optional>
an optional vector object where to set the converted value
Source:
viewport.js, line 480
Returns:
Type
me.Vector2d
Copyright © 2011 - 2017, Olivier Biot, Jason Oster, Aaron McLeod
Documentation generated by JSDoc 3.4.0 on 2017-02-28T11:37:42+08:00 using the DocStrap template modified by codename-.