Camera Library (ssk.camera.*)

A number of basic cameras you can use out-of-the-box, or that you can copy and modify to meet your specific game requirements/

Cameras

delayedTracking tracking
trackingLooseCircle trackingLooseRectangle

tracking

A camera that tracks the position of the trackObj exactly, keeping it in the exact position it started in or has specified to be at.

This camera supports the ability to track in only one axis and/or to adjust the tracking offset.

Tip: Deleting trackObj and/or the world display group before stopping the camera, you will crash your game. See Stopping Cameras below for more details.

ssk.camera.tracking( trackObj, world [ , params ]  )

-- Create some basic layers.
--
local layers = quickLayers( group, 
      "underlay",
      "world",
         { "circles", "player" },
      "overlay" )

local player = newImageRect( layers.player, centerX, centerY, "images/smiley.png" )

ssk.camera.tracking( player, layers.world )

delayedTracking

An experimental camera that waits a moment then moves to the new position of the trackObj.

Note: I don't use this one. It is meant to be a starting place for delayed cameras. If you need such a camera, examine this code and then write your own camera function.

Tip: Deleting trackObj and/or the world display group before stopping the camera, you will crash your game. See Stopping Cameras below for more details.

ssk.camera.delayedTracking(  )

trackingLooseCircle

trackingLooseCircle

A camera that tracks the trackObj continuously, but only moves the world once the trackObj moves beyond the radius of a dead zone. After that, world movement accelerates gradually to match that of trackObj.

Includes a debug feature to allow you to see the limits of the dead zone.

Tip: Deleting trackObj and/or the world display group before stopping the camera, you will crash your game. See Stopping Cameras below for more details.

ssk.camera.trackingLooseCircle( trackObj, world [ , params ]  )

trackingLooseRectangle

A camera that tracks the trackObj continuously, but only moves the world once the trackObj moves beyond the bounds of a rectangular dead zone. After that, world movement accelerates gradually to match that of trackObj.

Tip: Deleting trackObj and/or the world display group before stopping the camera, you will crash your game. See Stopping Cameras below for more details.

ssk.camera.trackingLooseRectangle( trackObj, world [ , params ]  )

Stopping Cameras

Once a camera has been started, it will run continously until it is stopped.

When a camera is started, it adds a method to the trackObj called stopCamera().

Stopping a previously started camera is a simple as:


player:stopCamera()

Tips


RoamingGamer Copyright © Roaming Gamer, LLC. 2008-2016; All Rights Reserved