I played around with the Drag & Drop feature of Ren'py.
https://www.renpy.org/dev-doc/html/drag_drop.html
Consider some kind of basketball situation with a (draggable) Drag called "drag_ball" that you can drag around, and there is also a (droppable) Drag called "drop_net" where you can drop the ball into.
Code: Select all
drag:
child "ball" # the image of the ball
drag_name "drag_ball"
draggable True
droppable False
dragged obj_dragged
drag:
child "net" # the image of the net
drag_name "drop_net"
draggable False
droppable True
Now it is easy to just drop the ball into the net following the Ren'py documentation. And it is also possible to let the "ball" snap to the bottom of the screen - using the Drag.snap function - if it was not directly put into the net, I figured that one out.
Code: Select all
def obj_dragged(drags, drop):
# the drag was not dropped onto a droppable drag
if not drop:
if drags[0].drag_name == "drag_ball":
# let the ball snap to the bottom of the screen within 1.0 seconds
drags[0].snap(drags[0].x, 600, 1.0)
# the drag was dropped onto a droppable drag
else:
if drop.drag_name == "drop_net":
# we hit the net
return True
return
1) Is it possible to trigger that the ball overlaps the net while snapping to the bottom of the screen when the player did release it above the net? I actually want the ball to fall down and when it is overlapping the net, a function should trigger.
2) Is it possible to trigger when the Drag.snap() function ended its animation of 1 seconds before the script moves on? (This would be a workaround for question 1 if the ball is at a certain position.)
3) I really don't understand what the drop_allowable function is doing. Can you help me?
Thank you!