Skip to content

Sprites

In Marmot, sprites are very easy to add:

class TestUI : MarmotUI("test_ui") {
fun new() {
group("test_group") {
val sprite = sprite("test_sprite") {
texturePath = "textures/block/dirt.png"
}
}
}
}

The result: UI Sprite Example


The size on the X and Y can also be controlled, stretching the image unless you scale by the same value on both axes:

val sprite = sprite("test_sprite") {
texturePath = "textures/block/dirt.png"
size = Vec2(64f, 32f)
}

The result: ui_sprite_stretch_example.png

val sprite = sprite("test_sprite") {
texturePath = "textures/block/dirt.png"
size = Vec2(64f, 64f)
}

The result: ui_sprite_correct_size_example.png