Camera.new()
Type | function |
Library | wattageTileEngine.Camera.* |
Return value | Camera |
Keywords | |
See also |
Overview
This function creates a new instance of Camera.
NOTE: This should never be necessary as an instance may be retrieved from the ViewControl.
Syntax
Camera.new( params )
params (required)
Table. Contains all required inputs. See Required Properties below.
Required Properties
The params
table contains the following properties:
x (required)
Number. X position of camera in tile units. Values increase from left to right.
y (required)
Number. Y position of camera in tile units. Values increase from top to bottom.
width (required)
Number. Width of the viewport in tile units.
height (required)
Number. Height of the viewport in tile units.
pixelWidth (required)
Number. Width of the viewport in pixels.
pixelHeight (required)
Number. Height of the viewport in pixels.
Examples
local TileEngine = require "plugin.wattageTileEngine"
local TILE_SIZE = 32
local CONTROL_WIDTH_IN_PIXELS = 320
local CONTROL_HEIGHT_IN_PIXELS = 256
local camera = TileEngine.Camera.new({
x = 0,
y = 0,
width = CONTROL_WIDTH_IN_PIXELS / TILE_SIZE,
height = CONTROL_HEIGHT_IN_PIXELS / TILE_SIZE,
pixelWidth = CONTROL_WIDTH_IN_PIXELS,
pixelHeight = CONTROL_HEIGHT_IN_PIXELS,
layer = 1
})