Sprite2D
Represents a sprite in the Kray game engine.
Properties
The x-component of the 2D acceleration of the Positionable2D object.
The y-component of the 2D acceleration of the Positionable2D object.
Whether the sprite can collide with other sprites. False means it cannot.
A set of all 2D sprites that are currently colliding with this sprite. Uses spatial hashing for O(n) average case complexity.
The current costume that the sprite is wearing.
The index of the current costume being used by this sprite.
The friction coefficient of the Positionable object. This is used in physics calculations to determine the frictional force acting on the object. The default value is defaultFrictionCoefficient.
Checks if the sprite is currently being clicked by the mouse.
Checks if the sprite is currently being middle-clicked by the mouse.
Checks if the sprite is currently being hovered over by the mouse.
Checks if the sprite is currently being right-clicked by the mouse.
The mass multiplier of the Positionable object. This is used in physics calculations to determine the effective mass of the object. The default value is 1.0.
The restitution coefficient of the Positionable object. This is used in physics calculations to determine how bouncy the object is after collisions. The default value is defaultRestitutionCoefficient.
The spin factor of the Positionable object.
The target rotation steps to move toward then on the ground.
The x-component of the 2D velocity of the Positionable2D object.
The y-component of the 2D velocity of the Positionable2D object
Functions
Adds a costume to this sprite.
Aligns the object to the left side of the screen.
Aligns the object to the left side of the target object.
Aligns the object to the top side of the screen.
Aligns the object to the right side of the target object.
Aligns the object to the bottom side of the screen.
Aligns the object to the bottom side of the target object.
Aligns the object to the top side of the screen.
Aligns the object to the top side of the target object.
Moves the sprite down when the given key is pressed.
Moves the sprite left when the given key is pressed.
Moves the sprite left when the given key is pressed.
Changes the current costume of this sprite to the next one in the list. Loops back to the first costume if currently at the last one.
Changes the current costume of this sprite to the previous one in the list. Loops back to the last costume if currently at the first one.
Removes the specified costume from this sprite.
Removes the costume at the specified index from this sprite.
Sets both the x and y components of the 2D acceleration of the Positionable2D object.
Sets the costume at the specified index for this sprite.
Sets the costumes for this sprite.
Sets the current costume of this sprite to the specified image. If the image is not already a costume of this sprite, it is added.
Sets both the x and y components of the 2D velocity of the Positionable2D object.