Spyral API Cheat Sheets¶
The following are convenient listings of the attributes and methods of some of the more common classes and modules.
Sprites¶
Attribute | Type | Description |
---|---|---|
pos | Vec2D | Sprite’s position within the parent |
x | int | Sprite’s horizontal position within the parent |
y | int | Sprite’s vertical position within the parent |
anchor | str (anchor point) | Where to offset this sprite |
image | Image | The image to display |
visible | bool | Whether or not to render this sprite |
layer | str (layering) | Which layer of the parent to place this sprite in |
width | float | Width of the sprite after all transforms |
height | float | Height of the sprite after all transforms |
size | Vec2D | Size of the sprite after all transforms |
rect | Rect | A rect describing size and position |
scale | Vec2D (can be set to float) | Scale factor for resizing the image |
scale_x | float | Scale factor for horizontally resizing the image |
scale_y | float | Scale factor for vertically resizing the image |
flip_x | bool | Whether the image should be flipped horizontally |
flip_y | bool | Whether the image should be flipped vertically |
angle | float | How much to rotate the image |
mask | Rect or None | Alternate size of collision box |
parent* | View or Scene | The immediate parent View or Scene |
scene* | Scene | The top-most parent Scene |
*Read-only
Scenes¶
Attribute | Type | Description |
---|---|---|
background | Image | The image to display as the static background |
layers** | list of str (layering) | The layers for this scene |
width* | int | Width of this scene internally (not the window). |
height* | int | Height of this scene internally (not the window). |
size* | Vec2D | Size of this scene internally (not the window). |
rect | Rect | A rect stretching from (0, 0) to the size of the window. |
parent* | Scene | This Scene |
scene* | Scene | This Scene |
*Read-only
** Can only be set once
Views¶
Attribute | Type | Description |
---|---|---|
pos | Vec2D | View’s position within the parent |
x | int | View’s horizontal position within the parent |
y | int | View’s vertical position within the parent |
width | float | Internal width of the view |
height | float | Internal height of the view |
size | Vec2D | Internal size of the view |
rect | Rect | A rect describing size and position |
anchor | str (anchor point) | Where to offset this view |
visible | bool | Whether or not to render this view |
layer | str (layering) | Which layer of the parent to place this view in |
layers** | list of str (layering) | The layers for this view |
scale | Vec2D (can be set to float) | Scale factor for resizing the view |
scale_x | float | Scale factor for horizontally resizing the view |
scale_y | float | Scale factor for vertically resizing the view |
output_width | float | Width of the view after all transforms |
output_height | float | Height of the view after all transforms |
output_size | Vec2D | Size of the sprite after all transforms |
crop | bool | Whether this View should be cropped |
crop_width | float | Horizontal amount to keep uncropped |
crop_height | float | Vertical amount to keep uncropped |
crop_size | Vec2D | Size of the uncropped region within the View |
mask | Rect or None | Alternate size of collision box |
parent* | View or Scene | The immediate parent View or Scene |
scene* | Scene | The top-most parent Scene |
*Read-only
** Can only be set once