WorldBullet
┗> Object > Class
The class that all World bullets in Kristal originate from.
Generic bullets can be spawned into the world with Game.world:spawnBullet(texture, x, y)
Files in scripts/world/bullets will also be loaded as world bullets and should Extend this class.
Extension bullets can be spawned into the world with Game.world:spawnBullet(id, ...) - their id defaults to their filepath, starting from scripts/world/bullets. Additional arguments ... are passed into the bullet type's init function.
Constructor
WorldBullet(x: number, y: number, texture: (string|love.Image)?)
Arguments:
| x: number | |
| y: number | |
| texture: (string|love.Image)? |
Methods
WorldBullet:isBullet(id: string)
Checks whether this bullet is an instance or extension of a specific bullet type, specified by id.
Arguments:
| id: string |
Returns:
| 1: boolean |
WorldBullet:onCollide(soul: OverworldSoul)
(Override) Called when the bullet collides with the player's soul, before invulnerability checks.
Arguments:
| soul: OverworldSoul | The soul of the player used when in the Overworld. |
WorldBullet:onDamage(soul: OverworldSoul)
(Override) Called when the bullet hits the player's soul without invulnerability frames.
Not calling super.onDamage() here will stop the normal damage logic from occurring.
Arguments:
| soul: OverworldSoul | The soul of the player used when in the Overworld. |
WorldBullet:setSprite(texture: (string|love.Image)?, speed: number?, loop: boolean?, on_finished: fun( any)?)
@param texture — The new texture or path to the texture to set on the sprite (Removes the bullet's sprite if undefined)
@param speed — The time between frames of the sprite, in seconds (Defaults to 1/30th second)
@param loop — Whether the sprite should continuously loop. (Defaults to true)
@param on_finished — A function that is called when the animation finishes.
Arguments:
| texture: (string|love.Image)? | The new texture or path to the texture to set on the sprite (Removes the bullet's sprite if undefined) |
| speed: number? | The time between frames of the sprite, in seconds (Defaults to 1/30th second) |
| loop: boolean? | Whether the sprite should continuously loop. (Defaults to |
| on_finished: fun( any)? | A function that is called when the animation finishes. |
Returns:
| 1: Sprite? |
Fields
WorldBullet.world: World
The current World instance. Not defined until after WorldBullet:init(), and only if it is parented to a World instance.
Undocumented
WorldBullet.sprite: Sprite
A simple object that renders a texture.
This texture must be placed inside assets/sprites/.