Skip to content

Dragosha/defold-sprite-repeat

Repository files navigation

Sprite texture repeat shader. (or tiling)

New version (sprites only)

Requires Defold ver. 1.12.4+

Just add tiling_material to your project and apply the material to your sprites.

You can add a material as a dependency to your project:

https://github.com/Dragosha/defold-sprite-repeat/archive/refs/heads/main.zip

Sprite setup

UV Repeat - repeat factor (how many tiles should be Made horizontally and vertically).

Translation - the direction and speed at which the sprite texture should move (scroll).

Color - the fill color (analogous to Tint).

Example

Note

Depending on the rotation of the sprite in the atlas, there may be confusion with the x,y tiling factor and the direction of movement. By default, if the sprite in the atlas is standing vertically, x corresponds to the horizontal direction, and y corresponds to the vertical direction. However, if the sprite is rotated, the x and y values will be reversed.

Old version


Set 'sprite_repeat' material to the sprite. Directly in the editor or with code.

go.set(self.url, "material", self.repeat_material)

Create and go our super-puper repeating magic.

local sprite_repeat = require('sprite_repeat.sprite_repeat')

function init(self)

	local repeat_x = 4
	local repeat_y = 4

	local sr = sprite_repeat.create("#sprite_url")
	sr.animate(repeat_x, repeat_y)

end

See file 'sprite_repeat.script' for details.

Works with both static and animated sprites.

Example

GUI box node texture repeat shader.


Set 'node_repeat' material to the box node. Directly in the editor or with code.

gui.set_material(node, "gui_repeat")

Setup constants to the material shader:

	local node_repeat = require('node_repeat.node_repeat')
	....
	local nr = node_repeat.create(node, nil, atlas_path)
	nr.animate(repeat_x, repeat_y)

Update the repeat factors if need:

	nr.update(1, 4*y)

See 'test.gui_script' for details.


Happy Defolding!


About

Texture repeat (tiling) shader. For Sprites and GUI box nodes.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors