Sprites for Processing
V2.1
|
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 |
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.
|
staticprotected |
Calculate the top-left and bottom-right world coordinates that is currently viewable on the screen.
|
static |
Deregister a sprite so that it is no longer managed by the library.
sprite | the sprite to be released from library control |
|
static |
Called from with the draw() method of your sketch. Causes all visible non-dead sprites to be displayed.
|
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.
enable |
|
static |
Moves the world's x/y position that corresponds to the top-left position on the screen.
x | |
y |
|
static |
Set the world's x/y position that corresponds to the top-left position on the screen.
x | |
y |
|
static |
Calculate the world position for the given screen position
px | |
py |
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.
mover0 | a moving sprite |
mover1 | a moving sprite |
|
static |
Register a sprite so that it will be updated with S4P.updateSprites(...) and drawn with S4P.drawSprites().
sprite | the sprite to be managed by this library |
|
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 |
Change the world display scale
A value of 1.0 gives 1:1 size correspondence with the screen
scale |
|
static |
Sorts the sprites so they are drawn in z order
Lower Z order values are drawn first. sort
|
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 |
Calculate the screen position for a given world position
wx | world X position |
wy | world Y position |
|
static |
Color used to show collision detect area. Recommend that you use a partially transparent colour.
|
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.
|
static |
Defines that area of the world that is being displayed World coordinates
|
static |
Color used to highlight selected sprite Recommend that you use a partially transparent colour.
|
staticprotected |
Ratio of screen to real world coordinates
|
staticprotected |
World coordinates corresponding to top-left of display
|
staticprotected |
World coordinates corresponding to top-left of display