Disclaimer: I've never touched Ren'Py Drag- and Drop before.
I want to drag 3840x1080 content horizontally. For now just the background, later additional imagebuttons must be moved with the background. The game's resolution is 1920x1080.
By default RenPy seems to prevent the user from dragging things off screen. It is assumed that the content is smaller than the screen. In my scenario drag_offscreen True is required to make large content draggable. Otherwise the image will just "jump" to the right side in this example and it stops dragging instantly. I guess this "jump" happens because Ren'Py tries to fit the 3840x1080 background on the 1920x1080 screen (with drag_offscreen False).
Question:
How can I prevent the user from dragging the content off screen in this example? Is it even possible in THIS scenario (image>screensize->drag_offscreen True)? The x,y position from the Callbacks is the obvious way to start, but these don't seem to "live"-update while dragging (event based?). So locking for example the y to 0 is pointless because the image would "jump" only back to a correct position when an event is fired. While dragging there is no event, no blocking possible? Right?
Test project with background attached (RenPy 7.1.1.929).
edit link for reference:
I want to drag 3840x1080 content horizontally. For now just the background, later additional imagebuttons must be moved with the background. The game's resolution is 1920x1080.
By default RenPy seems to prevent the user from dragging things off screen. It is assumed that the content is smaller than the screen. In my scenario drag_offscreen True is required to make large content draggable. Otherwise the image will just "jump" to the right side in this example and it stops dragging instantly. I guess this "jump" happens because Ren'Py tries to fit the 3840x1080 background on the 1920x1080 screen (with drag_offscreen False).
Code:
default debugtext = "Drag me!"
init python:
## https://www.renpy.org/doc/html/drag_drop.html
## after the drag has been rendered, the following fields become available:
## x,y,w,h
def drag_activated(drags):
store.debugtext = ""
for d in drags:
store.debugtext += "drag_activated()->"+d.drag_name+" x,y,w,h=("+str(d.x)+","+str(d.y)+","+str(d.w)+","+str(d.h)+")"
renpy.restart_interaction() # to update screen
return
def drag_dragged(drags, drop):
store.debugtext = ""
for d in drags:
store.debugtext += "drag_dragged()->"+d.drag_name+" x,y,w,h=("+str(d.x)+","+str(d.y)+","+str(d.w)+","+str(d.h)+")"
renpy.restart_interaction() # to update screen
return True
def drag_clicked():
store.debugtext = "drag_clicked()"
# no restart_interaction() needed, screen seems to update anyway
return True
screen photo_beach():
tag master
layer "master"
drag:
drag_name "photo_beach"
drag_handle (0,0,1.0,1.0)
drag_offscreen True # must be True for content larger than screensize
activated drag_activated
dragged drag_dragged
clicked drag_clicked
image "images/bg photo beach.jpg" # 3840x1080 background image
text debugtext align(0.5,0.5)
label start:
scene
show screen photo_beach
jump loop
label loop:
pause
jump loop
How can I prevent the user from dragging the content off screen in this example? Is it even possible in THIS scenario (image>screensize->drag_offscreen True)? The x,y position from the Callbacks is the obvious way to start, but these don't seem to "live"-update while dragging (event based?). So locking for example the y to 0 is pointless because the image would "jump" only back to a correct position when an event is fired. While dragging there is no event, no blocking possible? Right?
Test project with background attached (RenPy 7.1.1.929).
edit link for reference:
You must be registered to see the links