Class Index | File Index

Classes


Class Punx.Sprite


Defined in: punx.dist.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
Punx.Sprite(args)
A screen object.
Field Summary
Field Attributes Field Name and Description
 
fps
Sprite's framerate.
 
Animation frame index.
 
Keys animation frame group names to an array of integer arrays [x,y,w,h], the cropping information of the sheet for each animation frame.
 
Current/initial animation frame group name.
 
h
Sprite's height.
 
Required: Screen reference.
 
Sprite sheet to draw from.
 
w
Sprite's width.
 
x
Sprite's X offset.
 
y
Sprite's Y offset.
 
z
Sprite's "elevation".
Method Summary
Method Attributes Method Name and Description
<private>  
Called every frame-rated update.
<private>  
Called upon every update.
<static>  
Punx.Sprite.Actor(args)
 
collide(actor)
 
draw(ctx)
Sprite draws itself to the canvas context provided.
 
move(stage, direction, amount)
<static>  
Punx.Sprite.sort(a, b)
 
Called by the screen.
<static>  
Punx.Sprite.Wall(args)
Class Detail
Punx.Sprite(args)
A screen object.
Parameters:
{object} args
Construction values for public properties.
Field Detail
{int} fps
Sprite's framerate.

{int} frame
Animation frame index. Increments once per update, prior to step(). Automatically wraps at the length of the current group.

{object} frames
Keys animation frame group names to an array of integer arrays [x,y,w,h], the cropping information of the sheet for each animation frame. Required if sheet is set.

{string} group
Current/initial animation frame group name. Required if frames is set. Automatically wraps the animation frame index when set.

{int} h
Sprite's height.

{Punx.Screen} screen
Required: Screen reference.

{Image} sheet
Sprite sheet to draw from.

{int} w
Sprite's width.

{int} x
Sprite's X offset.

{int} y
Sprite's Y offset.

{int} z
Sprite's "elevation". 0 = floor tile, 1 = standing on ground, 2 = in air, 3 = sticky (health bar, etc)
Method Detail
<private> _step()
Called every frame-rated update. Unlike tick(), the return value is ignored as the sprite is considered updated on every frame-rated update. This is a stub.

<private> _tick()
Called upon every update. Returns boolean of whether the tick caused an update. This is a stub.
Returns:
?boolean

<static> Punx.Sprite.Actor(args)
Parameters:
args

collide(actor)
Parameters:
actor

draw(ctx)
Sprite draws itself to the canvas context provided. This is called by the screen once all sprites are updated and accounted for, such that when the sprite draws itself it will automatically layer properly. Automatically adjusts for Punx.Screen.Stage.x (panning). Does nothing if group isn't set. The sprite may be drawn multiple times during graphics analysis. Drawing should not change the sprite in any way.
Parameters:
ctx
Canvas context.

move(stage, direction, amount)
Parameters:
stage
direction
amount

<static> Punx.Sprite.sort(a, b)
Parameters:
a
b

update()
Called by the screen. The sprite should prepare itself to be drawn. Returns boolean of whether it was updated. Every update, tick() is called. Every frame-rated update, step() is called after the animation frame increments.
Returns:
bool

<static> Punx.Sprite.Wall(args)
Parameters:
args

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