Sprite

interface Sprite<T>

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).

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
abstract val isDrawn: Boolean

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

Link copied to clipboard
abstract var static: Boolean

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

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 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.