Sprites for Processing  V2.1
 All Classes Functions Variables
sprites.S4P Class Reference
Inheritance diagram for sprites.S4P:

Static Public Member Functions

static void resizeWorld (double scale)
 
static void resetWorld ()
 
static PointD2D pixel2world (double px, double py)
 
static Point world2pixel (double wx, double wy)
 
static void moveWorldTo (double x, double y)
 
static void moveWorldBy (double x, double y)
 
static void registerSprite (Sprite sprite)
 
static void deregisterSprite (Sprite sprite)
 
static void sortZorder ()
 
static void updateSprites (double deltaTime)
 
static void drawSprites ()
 
static boolean rebound (Sprite mover0, Sprite mover1)
 
static boolean rebound (Sprite mover0, Vector2D norm)
 
static void messagesEnabled (boolean enable)
 

Static Public Attributes

static boolean messages = true
 
static boolean collisionAreasVisible = false
 
static int colColor = 0x80ffff00
 
static int selColor = 0x8000ff00
 
static Domain screenDomain
 

Static Protected Member Functions

static void calcScreenDomain ()
 

Static Protected Attributes

static double worldX = 0.0f
 
static double worldY = 0.0f
 
static double worldScale = 1.0f
 

Detailed Description

This class is used to manage the sprites, it keeps track of all bitmap image files loaded to prevent multiple copies of the same image being loaded.

The main methods you are likely to use are update and draw ALL sprites.

Author
Peter Lager

Member Function Documentation

static void sprites.S4P.calcScreenDomain ( )
staticprotected

Calculate the top-left and bottom-right world coordinates that is currently viewable on the screen.

static void sprites.S4P.deregisterSprite ( Sprite  sprite)
static

Deregister a sprite so that it is no longer managed by the library.

Parameters
spritethe sprite to be released from library control
static void sprites.S4P.drawSprites ( )
static

Called from with the draw() method of your sketch. Causes all visible non-dead sprites to be displayed.

static void sprites.S4P.messagesEnabled ( boolean  enable)
static

S4P has a range of support messages eg
if you create a sprite component without an event handler.

This method allows the user to enable (default) or disable this option. If disable.

Parameters
enable
static void sprites.S4P.moveWorldBy ( double  x,
double  y 
)
static

Moves the world's x/y position that corresponds to the top-left position on the screen.

Parameters
x
y
static void sprites.S4P.moveWorldTo ( double  x,
double  y 
)
static

Set the world's x/y position that corresponds to the top-left position on the screen.

Parameters
x
y
static PointD2D sprites.S4P.pixel2world ( double  px,
double  py 
)
static

Calculate the world position for the given screen position

Parameters
px
py
Returns
the world position
static boolean sprites.S4P.rebound ( Sprite  mover0,
Sprite  mover1 
)
static

Collision detection
Calculates new velocities for the 2 game objects based on elastic collision.

It can also apply variable elasticity and friction to the collision.

Parameters
mover0a moving sprite
mover1a moving sprite
Returns
static void sprites.S4P.registerSprite ( Sprite  sprite)
static

Register a sprite so that it will be updated with S4P.updateSprites(...) and drawn with S4P.drawSprites().

Parameters
spritethe sprite to be managed by this library
static void sprites.S4P.resetWorld ( )
static

Reset the world so that the world origin is at the top-left corner of the screen and their is 1:1 correspondence between world and screen

static void sprites.S4P.resizeWorld ( double  scale)
static

Change the world display scale
A value of 1.0 gives 1:1 size correspondence with the screen

Parameters
scale
static void sprites.S4P.sortZorder ( )
static

Sorts the sprites so they are drawn in z order
Lower Z order values are drawn first. sort

static void sprites.S4P.updateSprites ( double  deltaTime)
static

Update the position, image animation etc for every sprite based on the time since the last time this method is called. This method should follow after a call to updateTime()

static Point sprites.S4P.world2pixel ( double  wx,
double  wy 
)
static

Calculate the screen position for a given world position

Parameters
wxworld X position
wyworld Y position
Returns
the screen position

Member Data Documentation

int sprites.S4P.colColor = 0x80ffff00
static

Color used to show collision detect area. Recommend that you use a partially transparent colour.

boolean sprites.S4P.collisionAreasVisible = false
static

If you want to see the collision area for the sprites then set to true.
This should only be done when testing collision detection because it uses a lot of memory creating images for pixel-pixel collision areas which is not released even if this is set back to false.

Domain sprites.S4P.screenDomain
static

Defines that area of the world that is being displayed World coordinates

int sprites.S4P.selColor = 0x8000ff00
static

Color used to highlight selected sprite Recommend that you use a partially transparent colour.

double sprites.S4P.worldScale = 1.0f
staticprotected

Ratio of screen to real world coordinates

double sprites.S4P.worldX = 0.0f
staticprotected

World coordinates corresponding to top-left of display

double sprites.S4P.worldY = 0.0f
staticprotected

World coordinates corresponding to top-left of display


The documentation for this class was generated from the following file: