Constructor
Wave()
This function is called when the wave is initialised. Waves are initialised before they are due to start,
so do not use this function to set up wave logic i.e. timers, bullets, objects, only use it for arena setup and setting fields such as time
.
See Wave:onStart()
for a suitable alternative.
Methods
Wave:beforeEnd()
(Override) Called when the wave is about to be ended
If this function returns true, the wave will not end
Returns:
1: boolean? |
Wave:clear()
Removes all objects spawned by this wave
Wave:onArenaEnter()
(Override) Called when the arena is created for the wave, before Wave:onStart()
has been called or the transition is completed.
If this function returns true, the wave will start immediately, without waiting for the arena transition
Returns:
1: boolean? |
Wave:onArenaExit()
(Override) Called when the arena finishes transitioning out after the wave
Wave:onEnd(death: boolean)
(Override) Called at the end of the wave
@param death
— Whether the wave is ending because the player is about to gameover
Arguments:
death: boolean | Whether the wave is ending because the player is about to gameover |
Wave:onStart()
(Override) Called at the start of the wave, when Wave:update()
starts being called.
Wave:setArenaOffset(x: number, y: number)
Sets the initial position of the arena, relative to its default starting position
Arguments:
x: number | |
y: number |
Wave:setArenaPosition(x: number, y: number)
Sets the initial position of the arena, relative to the topleft of the screen
Arguments:
x: number | |
y: number |
Wave:setArenaShape(: table<[number, number]>)
Sets the initial shape of the arena
@param ...
— A list of {x
, y
} vertices that form the shape of the arena.
Arguments:
: table<[number, number]> | A list of { |
Wave:setArenaSize(width: number, height: number)
Sets the initial size of the rectangular arena (Defaults to 142
by 142
pixels)
Arguments:
width: number | |
height: number |
Wave:setSoulOffset(x: number, y: number)
Sets the offset of the soul from its default starting position.
Arguments:
x: number | |
y: number |
Wave:setSoulPosition(x: number, y: number)
Sets the soul's starting position, relative to the topleft of the screen.
Arguments:
x: number | |
y: number |
Wave:spawnBullet(bullet: string|Bullet, : any)
Spawns a new bullet to this wave and parents it to Game.battle
.
@param bullet
— As a string, this parameter is either a sprite path, which will create a basic bullet with that sprite, or the id of a custom bullet. As a Bullet
, it will directly spawn that instance to the wave.
@param ...
— Additional arguments to be passed to the created bullet's init() function. Basic bullets take an x
and y
coordinate here.
@return bullet
— The newly added bullet instance.
Arguments:
bullet: string|Bullet | As a string, this parameter is either a sprite path, which will create a basic bullet with that sprite, or the id of a custom bullet. As a |
: any | Additional arguments to be passed to the created bullet's init() function. Basic bullets take an |
Returns:
bullet: Bullet | The newly added bullet instance. |
Wave:spawnBulletTo(parent: Object?, bullet: string|Bullet, : any)
Spawns a bullet and parents it to the parent
object.
@param parent
— The object to parent the bullet to. If left as nil
, will parent it to Game.battle
.
@param bullet
— As a string, this parameter is either a sprite path, which will create a basic bullet with that sprite, or the id of a custom bullet. As a Bullet
, it will directly spawn that instance to the wave.
@param ...
— Additional arguments to be passed to the created bullet's init() function. Basic bullets take an x
and y
coordinate here.
@return bullet
— The newly added bullet instance.
Arguments:
parent: Object? | The object to parent the bullet to. If left as |
bullet: string|Bullet | As a string, this parameter is either a sprite path, which will create a basic bullet with that sprite, or the id of a custom bullet. As a |
: any | Additional arguments to be passed to the created bullet's init() function. Basic bullets take an |
Returns:
bullet: Bullet | The newly added bullet instance. |
Wave:spawnObject(object: Object, x: number?, y: number?)
Spawns an object and parents it to Game.battle
Arguments:
object: Object | The base class of all objects in Kristal. |
x: number? | |
y: number? |
Returns:
1: Object |
Wave:spawnObjectTo(parent: Object, object: Object, x: number?, y: number?)
Spawns an object and parents it to the parent
object
Arguments:
parent: Object | The base class of all objects in Kristal. |
object: Object | The base class of all objects in Kristal. |
x: number? | |
y: number? |
Returns:
1: Object |
Wave:spawnSprite(texture: string|love.Image, x: number?, y: number?, layer: number?)
Spawns a sprite and parents it to Game.battle
Arguments:
texture: string|love.Image | |
x: number? | |
y: number? | |
layer: number? |
Returns:
1: Sprite |
Wave:spawnSpriteTo(parent: Object, texture: string|love.Image, x: number?, y: number?, layer: number?)
Spawns a sprite and parents it to the parent
object
Arguments:
parent: Object | The base class of all objects in Kristal. |
texture: string|love.Image | |
x: number? | |
y: number? | |
layer: number? |
Returns:
1: any |
Wave:update()
(Override) Called every frame after Wave:onStart()
has run
Fields
Wave.arena_height: number?
Wave arena rectangular height
Wave.arena_rotation: number
Wave arena rotation
Wave.arena_shape: table?
Wave arena shape (overrides rectangle options)
Wave.arena_width: number?
Wave arena rectangular width
Wave.arena_x: number?
Wave arena x-coordinate
Wave.arena_y: number?
Wave arena y-coordinate
Wave.finished: boolean
Whether the wave is finished or not
Wave.has_arena: boolean
Whether the wave should spawn the arena
Wave.soul_offset_x: number?
x-offset of the soul position at the start of the wave
Wave.soul_offset_y: number?
y-offset of the soul position at the start of the wave
Wave.soul_start_x: number?
x-coordinate the soul will transition to at the start of the wave
Wave.soul_start_y: number?
y-coordinate the soul will transition to at the start of the wave
Wave.time: number
The number of seconds the wave will last, or -1
for an infinite wave (Defaults to 5 seconds)
Undocumented
Wave.spawn_soul: boolean
Whether the wave should spawn the soul If this is false, the soul can be manually spawned with Wave:spawnSoul()
Wave.spawn_soul: boolean
Prevents weird shit from going down if this is called in the init function hopefully