Class Index | File Index

Classes


Class Punx.Screen.Stage


Defined in: punx.dist.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
stages are screens that are game levels.
Field Summary
Field Attributes Field Name and Description
<private>  
All in-frame and frame-edge actors, populated at the beginning of each update().
<private>  
All in-frame and frame-edge sprites, populated at the beginning of each update().
<private>  
All in-frame and frame-edge walls, populated at the beginning of each update().
 
h
Stage floor "depth".
 
How close the player can get to the edge of the frame before the camera pans.
 
Required.
 
w
Width of the stage.
 
x
Pan offset from house-left.
 
y
Stage floor Y offset.
Method Summary
Method Attributes Method Name and Description
<private>  
_collisions(resolution)
Checks in-frame actors for collision and notifies them.
<private>  
Draws the screen.
 
clips(actor, x, y)
Actors should call this to determine if they can move to a given position.
 
Determines in-frame and frame-edged sprites, pans, and draws and checks for collisions if needed.
Class Detail
Punx.Screen.Stage(args)
stages are screens that are game levels. they have "curtains" and a "floor". imagine looking upon a theater stage from an ideal balcony seat. curtains are used for backgrounds and parallax. the floor is the "depth" where actors move away from and toward the "front" of the stage. the defaults define the curtains and floor in terms of the golden ratio: http://en.wikipedia.org/wiki/Golden_ratio where the longer portion represents the curtains and the shorter portion is the floor.
Parameters:
args
Field Detail
<private> {Punx.Sprite.Actor[]} _actors
All in-frame and frame-edge actors, populated at the beginning of each update().

<private> {Punx.Sprite[]} _sprites
All in-frame and frame-edge sprites, populated at the beginning of each update().

<private> {Punx.Sprite.Wall[]} _walls
All in-frame and frame-edge walls, populated at the beginning of each update().

{int default 206} h
Stage floor "depth". The amount of freedom to move along the Y axis, relative to the bottom of the curtains, that actors have. This defaults to the remainder of the canvas height, but can be made shorter to prevent actors from moving too down-stage.

{int} panMargin
How close the player can get to the edge of the frame before the camera pans.
Default Value:
200

{Punx.Sprite.Actor.Player} player
Required. This is the actor which the camera pans for.

{int} w
Width of the stage. This can go beyond the viewport, the camera will pan with the player.
Default Value:
960

{int} x
Pan offset from house-left.
Default Value:
0

{int} y
Stage floor Y offset. This is the length of the "curtains", the bottom of which is up-stage. This is the height of the background area inaccessible to actors. This defaults to Phi-A of the default canvas height (540).
Default Value:
334
Method Detail
<private> _collisions(resolution)
Checks in-frame actors for collision and notifies them. This performs n(n-2)/2 AABB checks, subchecking pixels in intersecting areas to a semi-fine resolution (5 pixels), using the imaginary canvas. An actor is only collidable if its collidable flag is true. If an actor is collided and sets its collidable flag to false, any further checks on it are skipped. A pixel is only considered collidable if its opacity is >= 127, however, triggers (Punx.Sprite.Actor.Trigger) collide with just AABB. When two actors collide, both are notified via their collide() methods and given a reference to each other. The order of notification is undefined, so actors should only "be collided" and treat each other as read-only.
Parameters:
{number} resolution Optional, Default: 5
Integer pixel collision resolution, the number of pixels to skip per pixel check.

<private> _draw()
Draws the screen.

clips(actor, x, y)
Actors should call this to determine if they can move to a given position. This will ensure that actors stay on the stage floor and don't hit any walls. An actor can move close to the back of the stage, according to the Phi-B of their height. This is used as the actor's "depth".
Parameters:
{Punx.Sprite.Actor} actor
{int} x
Destination X coord
{int} y
Destination Y coord
Returns:
bool

update()
Determines in-frame and frame-edged sprites, pans, and draws and checks for collisions if needed.

Documentation generated by JsDoc Toolkit 2.4.0 on Thu Oct 03 2013 12:33:00 GMT-0700 (PDT)