Sprite

interface Sprite<T> : Positionable

Represents a sprite in the Kray game engine. Either 2D or 3D.

Parameters

T

The type of the sprite (e.g., Image for 2D sprites, Model for 3D sprites).

Inheritors

Properties

Link copied to clipboard
abstract var collideable: Boolean

Whether the sprite can collide with other sprites. False means it cannot.

Link copied to clipboard
abstract val costumes: MutableList<T>

A list of all costumes associated with this sprite.

Link copied to clipboard
open val currentCostume: T

The current costume that the sprite is wearing.

Link copied to clipboard
abstract val currentCostumeIndex: Int

The index of the current costume being used by this sprite.

Link copied to clipboard

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.

Link copied to clipboard
abstract override val id: ERROR CLASS: Symbol not found for Uuid

The ID of the sprite.

Link copied to clipboard
abstract val isDrawn: Boolean

Whether the sprite has been drawn to the canvas this frame.

Link copied to clipboard

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.

Link copied to clipboard

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.

Link copied to clipboard

The spin factor of the Positionable object.

Link copied to clipboard
abstract var static: Boolean

Whether the sprite is not affected by physics. True means it is not.

Link copied to clipboard
abstract var x: Float

The x-coordinate of the object.

Link copied to clipboard
abstract var y: Float

The x-coordinate of the object.

Functions

Link copied to clipboard
open fun addCostume(costume: T)

Adds a costume to this sprite.

Link copied to clipboard
abstract fun changeTo(index: Int)

Changes the current costume of this sprite to the one at the specified index.

Link copied to clipboard
abstract operator override fun equals(other: Any?): Boolean
Link copied to clipboard
abstract override fun hashCode(): Int
Link copied to clipboard
abstract fun nextCostume()

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.

Link copied to clipboard
abstract fun previousCostume()

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.

Link copied to clipboard
open fun removeCostume(costume: T)

Removes the specified costume from this sprite.

Link copied to clipboard
open fun removeCostumeAt(index: Int)

Removes the costume at the specified index from this sprite.

Link copied to clipboard
open fun setCostume(index: Int, costume: T)

Sets the costume at the specified index for this sprite.

Link copied to clipboard
open fun setCostumes(vararg list: T)
open fun setCostumes(list: Iterable<T>)

Sets the costumes for this sprite.

Link copied to clipboard
abstract fun setCurrentCostume(costume: T)

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.

Link copied to clipboard
abstract fun switchTo(costume: T)

Changes the current costume of this sprite to the specified image. The costume must already be part of this sprite's costumes.