local node_repeat = require('node_repeat.node_repeat')
function init(self)
self.box = node_repeat.create("box", nil, "/main/main.a.texturesetc")
self.box.animate(1, 1)
window.set_listener(function(_, event, data)
if event == window.WINDOW_EVENT_RESIZED then
local x, y = node_repeat.get_screen_aspect_ratio()
gui.set_size(self.box.node, vmath.vector3(data.width, data.height, 1))
gui.set_scale(self.box.node, vmath.vector3(1/x, 1/y, 1))
self.box.update(1*x, 1*y)
end
end)
end
Result:
As you can you can see if i try resize window width it works, but if i try resize window height background image is zooming not repeating, how prevent it?
Did you maybe have a chance to look at the newest example of a scrolling texture (working since 1.12.3):
Or an older one:
In your case, if you want the background not to move, there are some small adjustments needed.
For the issues with your code and why it’s not repeating vertically, I modified the code a bit.
That old helper normalized both axes by math.min(stretch_x, stretch_y), so it returned an aspect “correction” value, not a true repeat count that was needed in your case. In practice, that means one axis was staying at 1, so when you resized height the texture was zooming instead.
I changed it so the repeat uses the real window stretch on each axis:
node_repeat.lua now returns simply window_x / gui.get_width() and window_y / gui.get_height()
main.gui_script now applies those values (I moved code for this into a separate small function resize_background(), and I added one additional call for it once in init, at the beginning)