Sprites
Functions
Call For All Sprites
Call For All Sprites
Call the supplied function for all sprites in the current pack.
Parameters:
Name | Type | Description |
---|---|---|
fn | Sprite Float Function | The sprite function to call on all sprites. |
val | Float | The value passed to the function for each sprite. |
Signatures:
Call For All Sprites
Call the supplied function for all sprites in the current pack.
Parameters:
Name | Type | Description |
---|---|---|
fn | Sprite Function | The sprite function to call on all sprites. |
Signatures:
Call On Sprite Event
Register a procedure to be called when an events occur on any sprite.
Parameters:
Name | Type | Description |
---|---|---|
handler | Sprite Event Handler | The function to call when any sprite raises an event |
Signatures:
Center Point
Returns the center point of the passed in sprite. This is based on the sprite’s Position, Width and Height.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to get the details from. |
Return Type: Point 2d
Signatures:
Create Sprite
Create Sprite
Creates a sprite for the passed in bitmap image. The sprite will use the cell information within the bitmap if it is animated at a later stage. This version of create_sprite will initialise the sprite to use pixel level collisions, no animations, and have one layer named ‘layer1’. This version of the constructor will assign a default name to the sprite for resource management purposes.
Parameters:
Name | Type | Description |
---|---|---|
layer | Bitmap | The bitmap for the sprite’s image. |
Return Type: Sprite
Signatures:
Create Sprite
Creates a sprite for the passed in bitmap image. The sprite will use the cell information within the bitmap if it is animated at a later stage. This version of Create Sprite
will initialise the sprite to use pixel level collisions, the specified animation template, the layer have name ‘layer1’. This version of the constructor will assign a default name to the sprite for resource management purposes.
Parameters:
Name | Type | Description |
---|---|---|
layer | Bitmap | The bitmap for the sprite’s image. |
ani | Animation Script | The animation script for the sprite’s animations. |
Return Type: Sprite
Signatures:
Create Sprite
Creates a sprite for the passed in bitmap image. The sprite will use the cell information within the bitmap if it is animated at a later stage. This version of create_sprite will initialise the sprite to use pixel level collisions, no animations, and have one layer named ‘layer1’. This version of the constructor will assign a default name to the sprite for resource management purposes.
Parameters:
Name | Type | Description |
---|---|---|
bitmap_name | String | The name of the bitmap to use as the sprite’s layer |
Return Type: Sprite
Signatures:
Create Sprite
Creates a sprite for the passed in bitmap image. The sprite will use the cell information within the sprite if it is animated at a later stage. This version of create_sprite will initialise the sprite to use pixel level collisions, no animation, the layer have name ‘layer1’.
Parameters:
Name | Type | Description |
---|---|---|
name | String | The name of the sprite for resource management. |
layer | Bitmap | The bitmap for the sprite’s image. |
Return Type: Sprite
Signatures:
Create Sprite
Creates a sprite for the passed in bitmap image. The sprite will use the cell information within the sprite if it is animated at a later stage. This version of create_sprite will initialise the sprite to use pixel level collisions, the specified animation template, the layer have name ‘layer1’.
Parameters:
Name | Type | Description |
---|---|---|
name | String | The name of the sprite for resource management. |
layer | Bitmap | The bitmap for the sprite’s image. |
ani | Animation Script | The animation script for the sprite’s animations. |
Return Type: Sprite
Signatures:
Create Sprite
Creates a sprite. The bitmap_name is used to indicate the bitmap the sprite will use, and the animation_name is used to indicate which animation_script to use.
Parameters:
Name | Type | Description |
---|---|---|
bitmap_name | String | The name of the bitmap to use as the sprite’s image. |
animation_name | String | The name of the animation script to use for this sprite. |
Return Type: Sprite
Signatures:
Create Sprite Pack
Create a new sprite_pack with a given name. This pack can then be selected and used to control which sprites are drawn/updated in the calls to draw_all_sprites and update_all_sprites.
Parameters:
Name | Type | Description |
---|---|---|
name | String | The name of the new sprite pack. |
Signatures:
Current Sprite Pack
Returns the name of the currently selected sprite_pack.
Return Type: String
Signatures:
Draw All Sprites
draws all of the sprites in the current sprite pack. Packs can be switched to select between different sets of sprites.
Signatures:
Draw Sprite
Draw Sprite
Draws the sprite at its position in the game offset by a given amount. Only use this method when you want to draw the sprite displaced from its location in your game. Otherwise you should change the sprite’s location and then use the standard ”draw_sprite” routine.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to draw. |
offset | Vector 2d | The amount to offset the sprite. |
Signatures:
Draw Sprite
Draws the sprite at its location in the world. This is affected by the position of the camera and the sprites current location. This is the standard routine for drawing sprites to the screen and should be used in most cases.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to draw. |
Signatures:
Draw Sprite
Draws the sprite at its position in the game offset by a given amount. Only use this method when you want to draw the sprite displaced from its location in your game. Otherwise you should change the sprite’s location and then use the standard Draw Sprite
routine.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to draw. |
x_offset | Double | The amount to offset on the x axis. |
y_offset | Double | The amount to offset on the y axis. |
Signatures:
Free All Sprites
Releases all of the sprites that have been loaded.
Signatures:
Free Sprite
Free the resources associated with a sprite.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to be destroyed. |
Signatures:
Free Sprite Pack
Frees the sprite pack and all of its sprites.
Parameters:
Name | Type | Description |
---|---|---|
name | String | The name of the sprite pack to destroy. |
Signatures:
Has Sprite
Determines if SplashKit has a sprite for the supplied name. This checks against all sprites, those loaded without a name are assigned a default.
Parameters:
Name | Type | Description |
---|---|---|
name | String | The name of the sprite to locate. |
Return Type: Boolean
Signatures:
Has Sprite Pack
Indicates if a given sprite_pack has already been created.
Parameters:
Name | Type | Description |
---|---|---|
name | String | The name for the sprite pack. |
Return Type: Boolean
Signatures:
Move Sprite
Move Sprite
moves the sprite as indicated by its velocity. You can call this directly ot alternatively, this action is performed when the sprite is updated using the ”update_sprite” routine.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to move. |
Signatures:
Move Sprite
Moves the sprite a given distance based on the value passed in rather than based on the sprite’s velocity. Typically this method is used to apply other movement actions to the sprite and the velocity of the sprite is used the intended movement of the sprite.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to move. |
distance | Vector 2d | The vector that represents the direction and distance to move the sprite. |
Signatures:
Move Sprite
Moves the sprite a percentage of a given distance based on the value passed in rather than based on the sprite’s velocity. Typically this method is used to apply other movement actions to the sprite and the velocity of the sprite is used the intended movement of the sprite.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to move. |
distance | Vector 2d | The vector that represents the direction and distance to move the sprite. |
pct | Float | The percentage of the distance to move the sprite. |
Signatures:
Move Sprite
Moves the sprite as indicated by a percentage of its velocity. You can call this directly ot alternatively, this action is performed when the sprite is updated using the ”update_sprite” routines that require a percentage.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to move. |
pct | Float | The percentage of the sprite’s velocity to move. |
Signatures:
Move Sprite To
This method moves a sprite to a given position in the game.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to move. |
x | Double | The sprite’s new x location. |
y | Double | The sprite’s new y location. |
Signatures:
Select Sprite Pack
Selects the named sprite_pack (if it has been created). The selected sprite_pack determines which sprites are drawn and updated with the draw_all_sprites and update_all_sprites code.
Parameters:
Name | Type | Description |
---|---|---|
name | String | The name of the sprite pack to select. |
Signatures:
Sprite Add Layer
Adds a new layer to the sprite.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to add the layer to. |
new_layer | Bitmap | The new layer’s bitmap. |
layer_name | String | The name of the new layer. |
Return Type: Integer
Signatures:
Sprite Add To Velocity
Alters the current velocity of the sprite, adding the passed in vector_2d to the current velocity. When the sprite is updated (see Update Sprite
) this vector_2d is used to move the sprite.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to change. |
value | Vector 2d | The amount to add to the sprite’s velocity. |
Signatures:
Sprite Add Value
Sprite Add Value
Adds a new kind of value to the sprite
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to change. |
name | String | The name of the new value to store in the sprite. |
Signatures:
Sprite Add Value
Adds a new kind of value to the sprite, setting the initial value to the value passed in.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to change. |
name | String | The name of the new value to store in the sprite. |
init_val | Float | The initial value. |
Signatures:
Sprite Anchor Point
Returns the anchor point of the sprite. This is the point around which the sprite rotates. This is in sprite coordinates, so as if the sprite is drawn at 0,0.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to get the details from. |
Return Type: Point 2d
Signatures:
Sprite Anchor Position
The sprite anchor position, is the location of the anchor point in world coordinates, based upon the position of the sprite.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to find where the anchor is in world coordinates |
Return Type: Point 2d
Signatures:
Sprite Animation Has Ended
Indicates if the sprites animation has ended.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to get the details from. |
Return Type: Boolean
Signatures:
Sprite Animation Name
Returns the name of the sprite’s current animation.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to get the details from. |
Return Type: String
Signatures:
Sprite At
Determines if a sprite is at a given point.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to test |
pt | Point 2d | The point to check (in world coordinates) |
Return Type: Boolean
Signatures:
Sprite Bring Layer Forward
Sends the layer specified forward in the visible layer order.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to change |
visible_layer | Integer | The visible layer to bring forward |
Signatures:
Sprite Bring Layer To Front
Sends the layer specified to the front in the visible layer order.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to change |
visible_layer | Integer | The visible layer to bring to the front |
Signatures:
Sprite Call On Event
Register a procedure to call when events occur on the sprite.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to add the handler to. |
handler | Sprite Event Handler | The function to call when this sprite raises an event. |
Signatures:
Sprite Circle
Gets a circle in the bounds of the base layer of the indicated sprite.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to get the details from. |
Return Type: Circle
Signatures:
Sprite Collision Bitmap
Returns the bitmap used by the sprite to determine if it has collided with other objects in the game.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to get the details from. |
Return Type: Bitmap
Signatures:
Sprite Collision Circle
Gets a circle in the bounds of the indicated sprite’s collision rectangle.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to get the details from. |
Return Type: Circle
Signatures:
Sprite Collision Kind
Returns the kind of collision used with this sprite. This is used when determining if the sprite has collided with other objects in the game.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to get the details from. |
Return Type: Collision Test Kind
Signatures:
Sprite Collision Rectangle
Returns the collision rectangle for the specified sprite.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to get the details from. |
Return Type: Rectangle
Signatures:
Sprite Current Cell
Returns the current animation cell for an animated sprite. The cell is updated when the sprite’s animation data is updated.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to get the details from. |
Return Type: Integer
Signatures:
Sprite Current Cell Rectangle
Returns a rectangle of the current cell within the sprite’s image. This is used to determine what part of the bitmap should be used when the sprite is drawn.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to get the details from. |
Return Type: Rectangle
Signatures:
Sprite Dx
Returns the X value of the sprite’s velocity.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to get the details from. |
Return Type: Float
Signatures:
Sprite Dy
Returns the Y value of the sprite’s velocity.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to get the details from. |
Return Type: Float
Signatures:
Sprite Has Value
Indicates if the sprite has a value with the given name.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to get the details from. |
name | String | The name of the value to check. |
Return Type: Boolean
Signatures:
Sprite Heading
Returns the direction the sprite is heading in degrees.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to get the details from. |
Return Type: Float
Signatures:
Sprite Height
The current height of the sprite (aligned to the Y axis).
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to get the details from. |
Return Type: Integer
Signatures:
Sprite Hide Layer
Sprite Hide Layer
Hide the specified layer of the sprite.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to hide the layer of. |
name | String | The name of the layer to hide. |
Signatures:
Sprite Hide Layer
Hide the specified layer of the sprite.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to hide the layer of. |
id | Integer | The index of the layer to hide. |
Signatures:
Sprite Layer
Sprite Layer
Returns the bitmap of the indicated layer of the sprite.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to get the layer from |
name | String | The name of the layer to fetch |
Return Type: Bitmap
Signatures:
Sprite Layer
Returns the bitmap of the indicated layer of the sprite.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to get the layer from |
idx | Integer | The index of the layer |
Return Type: Bitmap
Signatures:
Sprite Layer Circle
Sprite Layer Circle
Gets a circle in the bounds of the indicated layer.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to get the details from. |
name | String | The name of the layer. |
Return Type: Circle
Signatures:
Sprite Layer Circle
Gets a circle in the bounds of the indicated layer.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to get the details from. |
idx | Integer | The index of the layer. |
Return Type: Circle
Signatures:
Sprite Layer Count
Returns the number of layers within the sprite.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to get the layer count from. |
Return Type: Integer
Signatures:
Sprite Layer Height
Sprite Layer Height
The height of a given layer of the sprite (aligned to the Y axis).
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to get the details from. |
name | String | The name of the layer to get the details of. |
Return Type: Integer
Signatures:
Sprite Layer Height
The height of a given layer of the sprite (aligned to the Y axis).
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to get the details from. |
idx | Integer | The index of the layer to get the details of. |
Return Type: Integer
Signatures:
Sprite Layer Index
Returns the index of the specified layer.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to get the layer from |
name | String | The name of the layer to get the index of |
Return Type: Integer
Signatures:
Sprite Layer Name
Returns the name of the specified layer.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to get the layer name from |
idx | Integer | The index of the layer you want the name of |
Return Type: String
Signatures:
Sprite Layer Offset
Sprite Layer Offset
Gets the offset of the specified layer.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to get the details from. |
name | String | The name of the layer to get the offset of. |
Return Type: Vector 2d
Signatures:
Sprite Layer Offset
Gets the offset of the specified layer.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to get the details from. |
idx | Integer | The index of the layer to get the offset of. |
Return Type: Vector 2d
Signatures:
Sprite Layer Rectangle
Sprite Layer Rectangle
Gets a rectangle that surrounds the indicated layer.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to get the details from. |
name | String | The name of the layer. |
Return Type: Rectangle
Signatures:
Sprite Layer Rectangle
Gets a rectangle that surrounds the indicated layer.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to get the details from. |
idx | Integer | The index of the layer. |
Return Type: Rectangle
Signatures:
Sprite Layer Width
Sprite Layer Width
The width of a given layer of the sprite (aligned to the X axis).
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to get the details from. |
name | String | The name of the layer to get the details of. |
Return Type: Integer
Signatures:
Sprite Layer Width
The width of a given layer of the sprite (aligned to the X axis).
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to get the details from. |
idx | Integer | The index of the layer to get the details of. |
Return Type: Integer
Signatures:
Sprite Location Matrix
Returns a matrix that can be used to transform points into the coordinate space of the passed in sprite.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to get the details from. |
Return Type: Matrix 2d
Signatures:
Sprite Mass
This indicates the mass of the sprite for any of the collide methods from Physics. The mass of two colliding sprites will determine the relative velocitys after the collision.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to get the details from. |
Return Type: Float
Signatures:
Sprite Move From Anchor Point
Indicates if the sprite is moved from its anchor point, or from its top left. When this returns true the location of the sprite will indicate its anchor point. When this returns false the location of the sprite is its top left corner.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to get the details of. |
Return Type: Boolean
Signatures:
Sprite Move To
This void starts the sprite moving to the indicated destination point, over a specified number of seconds. When the sprite arrives it will raise the sprite_arrived event.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to move. |
pt | Point 2d | The sprite’s destination. |
taking_seconds | Float | The time the sprite should take to get to pt. |
Signatures:
Sprite Name
Returns the name of the sprite. This name is used for resource management and can be used to interact with the sprite in various routines.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to get the details from. |
Return Type: String
Signatures:
Sprite Named
Returns the Sprite
with the specified name.
Parameters:
Name | Type | Description |
---|---|---|
name | String | The name of the sprite to locate. |
Return Type: Sprite
Signatures:
Sprite Offscreen
Returns true if the sprite is entirely off the current screen.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to test. |
Return Type: Boolean
Signatures:
Sprite On Screen At
Sprite On Screen At
Returns true if a pixel of the Sprite
s
is at the screen location specified (pt
), which is converted to a world location.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to test. |
pt | Point 2d | The location in screen coordinates to check. |
Return Type: Boolean
Signatures:
Sprite On Screen At
Returns true if a pixel of the Sprite
s
is at the screen location specified.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to test. |
x | Double | The x location in screen coordinates to check. |
y | Double | The y location in screen coordinates to check. |
Return Type: Boolean
Signatures:
Sprite Position
Returns the sprite’s position.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to get the details from. |
Return Type: Point 2d
Signatures:
Sprite Replay Animation
Sprite Replay Animation
Restart the sprite’s current animation, this will play a sound if the first cell of the animation is associated with a sound effect.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to replay the animation of. |
Signatures:
Sprite Replay Animation
Restart the sprite’s current animation, this will play a sound if with_sound is true and the first cell of the animation is associated with a sound effect.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to replay the animation of. |
with_sound | Boolean | If false, the animation will not play associated sound effects when restarted. |
Signatures:
Sprite Rotation
This indicates the angle of rotation of the sprite. This will rotate any images of the sprite before drawing, which can be very slow. avoid using this method with bitmap based sprites where possible.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to get the details from. |
Return Type: Float
Signatures:
Sprite Scale
This indicates the scale of the sprite. This will scale any images of the sprite before drawing, which can be very slow. avoid using this method with bitmap based sprites where possible.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to get the details from. |
Return Type: Float
Signatures:
Sprite Screen Rectangle
Returns the rectangle representing the location of the sprite on the screen.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to get the details from. |
Return Type: Rectangle
Signatures:
Sprite Send Layer Backward
Sends the layer specified backward in the visible layer order.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to change |
visible_layer | Integer | The visible layer to send to backward |
Signatures:
Sprite Send Layer To Back
Sends the layer specified to the back in the visible layer order.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to change |
visible_layer | Integer | The visible layer to send to back |
Signatures:
Sprite Set Anchor Point
Allows you to set the anchor point for the sprite. This is the point around which the sprite rotates. This is in sprite coordinates, as if the sprite is drawn at 0,0.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to change. |
pt | Point 2d | The new anchor point in sprite coordinates. |
Signatures:
Sprite Set Collision Bitmap
Sets the bitmap used by the sprite to determine if it has collided with other objects in the game. By default the collision_bitmap is set to the bitmap from the sprite’s first layer.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to change. |
bmp | Bitmap | The new collision bitmap for the sprite. |
Signatures:
Sprite Set Collision Kind
Sets the kind of collision used with this sprite. This is used when determining if the sprite has collided with other objects in the game.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to change. |
value | Collision Test Kind | The new kind of collision test for this sprite. |
Signatures:
Sprite Set Dx
Sets the X value of the sprite’s velocity.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to change. |
value | Float | The new x component of the sprite’s velocity. |
Signatures:
Sprite Set Dy
Sets the Y value of the sprite’s velocity.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to change. |
value | Float | The new y component of the sprite’s velocity. |
Signatures:
Sprite Set Heading
Alters the direction the sprite is heading without changing the speed.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to change. |
value | Float | The new angle for the sprite’s velocity — distance remains the same. |
Signatures:
Sprite Set Layer Offset
Sprite Set Layer Offset
Sets the offset of the specified layer. The offset is used when the layer is drawn in the sprite, and moves the image relative to the sprite.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to change. |
name | String | The name of the layer to change. |
value | Vector 2d | The new offset. |
Signatures:
Sprite Set Layer Offset
Sets the offset of the specified layer.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to change. |
idx | Integer | The index of the layer to change. |
value | Vector 2d | The new offset. |
Signatures:
Sprite Set Mass
Allows you to change the mass of a sprite.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to change. |
value | Float | The new mass for the sprite. |
Signatures:
Sprite Set Move From Anchor Point
Allows you to indicate if the sprite is moved from its anchor point, or from its top left. When set to true the location of the sprite will be its anchor point. When set to false the location of the sprite is its top left corner.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to change. |
value | Boolean | The value to set this option. |
Signatures:
Sprite Set Position
Sets the sprite’s position.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to change. |
value | Point 2d | The new location for the sprite. |
Signatures:
Sprite Set Rotation
Allows you to change the rotation of a sprite.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to change. |
value | Float | The new rotation angle for the sprite |
Signatures:
Sprite Set Scale
Allows you to change the scale of a sprite.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to change. |
value | Float | The new scale for the sprite. |
Signatures:
Sprite Set Speed
Alters the speed of the sprite without effecting the direction.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to change. |
value | Float | The new speed of the sprite — direction will remain the same. |
Signatures:
Sprite Set Value
Assigns a value to the sprite.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to change. |
name | String | The name of the value to change |
val | Float | The new value. |
Signatures:
Sprite Set Velocity
Sets the current velocity of the sprite. When the sprite is updated (see Update Sprite
) this vector_2d is used to move the sprite.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to change. |
value | Vector 2d | The new sprite velocity. |
Signatures:
Sprite Set X
Sets the X position of the sprite.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to change. |
value | Float | The new x location. |
Signatures:
Sprite Set Y
Sets the Y position of the sprite.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to change. |
value | Float | The new sprite y. |
Signatures:
Sprite Show Layer
Sprite Show Layer
Show the specified layer of the sprite.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to show the layer of. |
name | String | The layer to show. |
Return Type: Integer
Signatures:
Sprite Show Layer
Show the specified layer of the sprite.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to show the layer of. |
id | Integer | The index to show. |
Return Type: Integer
Signatures:
Sprite Speed
Returns the current speed (distance travelled per update) of the sprite.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to get the details from. |
Return Type: Float
Signatures:
Sprite Start Animation
Sprite Start Animation
Start playing an animation from the sprite’s animation template. This will play a sound effect if the first cell of the animation has a sound.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to start the animation of. |
named | String | The name of the animation to start from the animation script. |
Signatures:
Sprite Start Animation
Start playing an animation from the sprite’s animation template. The with_sound parameter determines whether to play a sound effect if the first cell of the animation has a sound.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to start the animation of. |
named | String | The name of the animation to start from the animation script. |
with_sound | Boolean | If false, the animation will not play associated sound effects when started. |
Signatures:
Sprite Start Animation
Start playing an animation from the sprite’s animation template. This will play a sound effect if the first cell of the animation has a sound.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to start the animation of. |
idx | Integer | The index of the animation to start from the animation script. |
Signatures:
Sprite Start Animation
Start playing an animation from the sprite’s animation template. The with_sound parameter determines whether to play a sound effect if the first cell of the animation has a sound.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to start the animation of. |
idx | Integer | The index of the animation to start from the animation script. |
with_sound | Boolean | If false, the animation will not play associated sound effects when started. |
Signatures:
Sprite Stop Calling On Event
Removes an event handler from the sprite, stopping events from this sprite calling the indicated method.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to remove the handler from |
handler | Sprite Event Handler | The function to remove from this sprites handlers |
Signatures:
Sprite Toggle Layer Visible
Sprite Toggle Layer Visible
Toggle the visibility of the specified layer of the sprite.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to change. |
name | String | The name of the layer to toggle. |
Signatures:
Sprite Toggle Layer Visible
Toggle the visibility of the specified layer of the sprite.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to change. |
id | Integer | The index of the layer to toggle. |
Signatures:
Sprite Value
Returns the indicated value of the sprite
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to get the details from. |
name | String | The name of the value to fetch. |
Return Type: Float
Signatures:
Sprite Value Count
Returns the number of sprite’s values.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to get the details from. |
Return Type: Integer
Signatures:
Sprite Velocity
Returns the current velocity of the sprite. When the sprite is updated (see Update Sprite
) this vector_2d is used to move the sprite.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to get the details from. |
Return Type: Vector 2d
Signatures:
Sprite Visible Index Of Layer
Sprite Visible Index Of Layer
Returns the index (z-order) of the sprite’s layer.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to get the details from. |
name | String | The name of the layer to get the z index of. |
Return Type: Integer
Signatures:
Sprite Visible Index Of Layer
Returns the index (z-order) of the sprite’s layer.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to get the details from. |
id | Integer | The index of the layer to get the z index of. |
Return Type: Integer
Signatures:
Sprite Visible Layer
Returns the index of the n’th (idx parameter) visible layer.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to get the details from. |
idx | Integer | The index of the visible layer to fetch. |
Return Type: Integer
Signatures:
Sprite Visible Layer Count
Returns the number of layers that are currently visible for the sprite.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to get the details from. |
Return Type: Integer
Signatures:
Sprite Visible Layer Id
Returns the id of the layer at index idx
that is currently visible. Index 0 is the background, with larger indexes moving toward the foreground. This returns -1 if there are no visible layers.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to get the details from. |
idx | Integer | The index of the visible layer. |
Return Type: Integer
Signatures:
Sprite Width
The current Width of the sprite (aligned to the X axis).
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to get the details from. |
Return Type: Integer
Signatures:
Sprite X
Returns the X position of the sprite.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to get the details from. |
Return Type: Float
Signatures:
Sprite Y
Returns the Y position of the sprite.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to get the details from. |
Return Type: Float
Signatures:
Stop Calling On Sprite Event
Removes an global event handler, stopping events calling the indicated void.
Parameters:
Name | Type | Description |
---|---|---|
handler | Sprite Event Handler | The function to remove from the list of sprite event handlers. |
Signatures:
Update All Sprites
Update All Sprites
Update all of the sprites in the current sprite pack.
Signatures:
Update All Sprites
Update all of the sprites in the current sprite pack, passing in a percentage value to indicate the percentage to update.
Parameters:
Name | Type | Description |
---|---|---|
pct | Float | The percentage of the update to apply. |
Signatures:
Update Sprite
Update Sprite
Update the position and animation details of the sprite. This will play a sound effect if the new cell of the animation has a sound.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to update. |
Signatures:
Update Sprite
Update the position and animation details of the sprite. This will play a sound effect if the new cell of the animation has a sound and with_sound is true.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to update |
with_sound | Boolean | If false, animations will not play associated sound effects when updated. |
Signatures:
Update Sprite
Update the position and animation details of the sprite by a given percentage of a single unit of movement/animation. This will play a sound effect if the new cell of the animation has a sound.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to update. |
pct | Float | The percent to update. |
Signatures:
Update Sprite
Update the position and animation details of the sprite by a given percentage of a single unit of movement/animation. This will play a sound effect if the new cell of the animation has a sound and with_sound is true.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to update. |
pct | Float | The percent to update. |
with_sound | Boolean | If false, animations will not play associated sound effects when updated. |
Signatures:
Update Sprite Animation
Update Sprite Animation
Updates the animation details of the sprite. This will play a sound effect if the new cell of the animation has a sound.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to update. |
Signatures:
Update Sprite Animation
Update the animation details of the sprite. This will play a sound effect if the new cell of the animation has a sound and with_sound is true.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to update. |
with_sound | Boolean | If false, animations will not play associated sound effects when updated. |
Signatures:
Update Sprite Animation
Update the animation details of the sprite by a given percentage of a single unit of movement/animation. This will play a sound effect if the new cell of the animation has a sound.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to update. |
pct | Float | The percent to update. |
Signatures:
Update Sprite Animation
Update the position and animation details of the sprite by a given percentage of a single unit of movement/animation. This will play a sound effect if the new cell of the animation has a sound and with_sound is true.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to update. |
pct | Float | The percent to update. |
with_sound | Boolean | If false, animations will not play associated sound effects when updated. |
Signatures:
Vector From Center Sprite To Point
Returns a Vector 2d
that is the difference in location from the center of the sprite s
to the point pt
.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite that is at the start of the vector. |
pt | Point 2d | The point that is at the end of the vector. |
Return Type: Vector 2d
Signatures:
Vector From To
Returns a Vector 2d
that is the difference in the position of two sprites (s1
and s2
).
Parameters:
Name | Type | Description |
---|---|---|
s1 | Sprite | The sprite that is at the start of the vector. |
s2 | Sprite | The sprite that is at the end of the vector. |
Return Type: Vector 2d
Signatures:
Types
Collision Test Kind
Constant | Value | Description |
---|---|---|
PIXEL_COLLISIONS | The sprite will check for collisions with its collision bitmap. | |
AABB_COLLISIONS | The sprite will check for collisions with a bounding box around the sprite. |
This enumeration can be used to set the kind of collisions a sprite will check for.
Sprite
Sprites combine an image, with position and animation details. You can
create a sprite using Create Sprite
, draw it with Draw Sprite
, move it
using the Sprite Velocity
with Update Sprite
, and animate it using an
Animation Script
.
Sprite Event Handler
The sprite_event_handler function pointer is used when you want to register to receive events from a Sprite.
Sprite Event Kind
Constant | Value | Description |
---|---|---|
SPRITE_ARRIVED_EVENT | The sprite has arrived at the end of a move | |
SPRITE_ANIMATION_ENDED_EVENT | The Sprite’s animation has ended. | |
SPRITE_TOUCHED_EVENT | The Sprite was touched | |
SPRITE_CLICKED_EVENT | The Sprite was touched |
This enumeration contains a list of all of the different kinds of events that a Sprite can raise. When the event is raised the assocated sprite_event_kind value passed to the event handler to indicate the kind of event that has occurred.
Sprite Float Function
The sprite single function is used with sprite packs to provide a procedure to be called for each of the Sprites in the sprite pack, where a float value is required.
Sprite Function
sprite_function is used with SpritePacks to provide a procedure to be called for each of the Sprites in the SpritePack.