So I have a kind of weird thing I'm trying to do with the viewports.
Basically I want it so if it's scrolled past a certain point, it'd snap to the max range of the viewport, otherwise it resets back to 0
Think like when you're swiping between home screens on a phone -- if you get past half when you release the swipe, it auto snaps to the next home screen. Otherwise, it resets back to the home screen you were on instead of changing to the next home screen.
So far I've managed to get it to snap to the next screen if you get past a certain point of scroll, but I'm unable to have it reset back to 0 if you don't get past that point. This is what I have so far:
Code: Select all
default xvalue = 1
default xadjtest = ui.adjustment(range=1920, page=1020, value=store.xvalue, changed=changevpscroll)
init python:
def changevpscroll(x):
global xvalue
if xvalue < x:
if x > 900:
renpy.run(Scroll("vptest", direction = "horizontal increase"))
else:
if x < 900:
renpy.run(Scroll("vptest", direction = "horizontal decrease"))
xvalue = x
Code: Select all
viewport id "vptest":
mousewheel False
draggable True
xinitial 0.0
pos (0, 0)
xysize (1920, 1080)
child_size (3840, 1080)
xadjustment xadjtest
hbox:
spacing 0
add "test1"
add "test2"
Failed version below of the function
Code: Select all
if xvalue < x:
if x > 900:
renpy.run(Scroll("vptest", direction = "horizontal increase"))
else:
renpy.run(Scroll("vptest", direction = "horizontal decrease"))
Code: Select all
viewport_drag_start = [ 'mousedown_1' ],
viewport_drag_end = [ 'mouseup_1' ]
So now I'm unsure what to do. I'm reluctant to give up on this since I feel like I'm already halfway there but I'm stuck LOL. Any help would be much appreciated!
Thank you!