Skip to content
Marcus Mascord edited this page Jul 11, 2014 · 6 revisions

The Screen widget needs specific explanation. The HTML5 tag has been specified as:

<canvas id="canvasName" width="320px" height="480px"></canvas>

The page will have a rectangular canvas with the width of 320, and the height of 480. When initialising Swanc it is necessary to pass in the id of the canvas to be used, in this case “canvasName”.

Swanc will automatically create the Screen widget on initialisation. This is the representation of the canvas, within Swanc.

Every widget we add will be added to the Screen widget. For that reason the Screen widget is a container widget because it contains other widgets.

The Screen widget can therefore be considered as the root widget to which all other widgets belong. It has the exact same width and height that has been specified in the HTML5 canvas tag.

To obtain the Screen widget in JavaScript use the function:

    `var screen = mm.App.getScreen();`

The attributes for the Screen widget are the following:

Attributes Type Description
m Widget The main widget class.
originalWidth Integer This is the size of the screen the application was initially developed for. If this is not set to null, all the other widgets will scale to this width.
originalHeight Integer This is the size of the screen the application was initially developed for. If this is not set to null, all the other widgets will scale to this height.
scaleX Float The scale currently being used for x. Only if originalWidth != null.
scaleY Float The scale currently being used for y. Only if originalHeight != null.
Clone this wiki locally