API Docs for: 1.0.1

Grape.AbstractView Class

Provides a viewport to the game. The dimension properties (width, height, left, top, originX, originY) are calculated dynamically. You can set these properties as functions or evaluated strings, like '30%+40'.

Constructor

Grape.AbstractView

(
  • opts
)

Parameters:

  • opts Object

    Initial properties

Methods

createDom

() HTMLElement

This abstract method should create the HTMLElement which serves

Returns:

HTMLElement:

Canvas

getHeight

() Number

Returns the calculated height value.

Returns:

Number:

calculated height

getLayer

() Grape.Layer | Undefined

Returns the layer the system is added to.

Returns:

Grape.Layer | Undefined:

The layer

getLeft

() Number

Returns the calculated width left.

Returns:

Number:

calculated left

getOriginX

() Number

Returns the calculated originX value.

Returns:

Number:

calculated originX

getOriginY

() Number

Returns the calculated originY value.

Returns:

Number:

calculated originY

getTop

() Number

Returns the calculated top value.

Returns:

Number:

calculated top

getWidth

() Number

Returns the calculated width value.

Returns:

Number:

calculated width

updateSize

()

This method is called in each render frame, and should be update the displayed element's width. The default functionality is setting the style width and height, but for canvas it is different.

Properties

alpha

Number

The global alpha value of the view.

Default: 1

height

String | Number | Function

The height of the view. The maximum value (100%) is the container height.

Default: '100%'

left

String | Number | Function

The left axis of the view in the container. The maximum value (100%) is the container width.

Default: 0

mouse

Number

Information about the mouse relative to the view.

originX

String | Number | Function

The horizontal origin of the view. Tells where should a point with x = view.x appear on the screen. The maximum value (100%) is the width of the view.

Default: 0

originY

String | Number | Function

The vertical origin of the view. Tells where should a point with y = view.y appear on the screen. The maximum value (100%) is the height of the view.

Default: 0

top

String | Number | Function

The top axis of the view in the container. The maximum value (100%) is the container height.

Default: 0

width

String | Number | Function

The width of the view. The maximum value (100%) is the container width.

Default: '100%'

x

Number

The x coordinate of the showed area.

Default: 0

y

Number

The y coordinate of the showed area.

Default: 0

Events

domCreated

This event is fired after the createDom() method is called and the DOM element is appended to the container. The parameter is the element.

mouseMoveView (layer)

Emitted to the containing layer when the mouse position changed according to the position in the previous frame. The parameter is the view.