rows If the sprite asset is a sprite sheet, the number of rows in the sprite sheet. Default: 1
cols If the sprite asset is a sprite sheet, the number of columns in the sprite sheet. Default: 1
Return
A sprite, which can be assigned to an object.
get_bounds(obj: gameobject) -> dict
Example
Description
Get the bounds of an object. Bounds uses the sprite assigned to the object and considers the angle, scale, x and y position of the object
Parameters
obj The game object to check the bounds for
Return
Returns a dictionary with keys: topLeft, topRight, bottomLeft, bottomRight with its corresponding values.
get_width(obj: gameobject) -> int || get_height(obj: gameobject) -> int
Example
Description
gets the width or height of an object with a sprite assigned. This will consider scaleX and scaleY but does not consider the angle of the object.
Parameters
obj The game object to check the bounds for
Return
get_width() returns the width of the object in pixels. get_height() returns the height of the object in pixels.
Sprites
Sprites are pictures. In PixelPAD, every object has a sprite assigned
to it that says how the object looks in the game. A sprite is ultimately
just an image file uploaded from your computer. You can add one by using
the green plus sign (+) on the ASSETS sidebar. To load a sprite from within
a script, use the new_sprite function.
Every GameObject class contains a variable called “sprite”. All we have to
do is set the variable to the image you want and the PixelPAD2D game engine
handles it from there. Check out the method new_sprite as it gives essential
examples.