Is it possible to add an animation when Draggable objects snaps to Droppable?

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
Wimble
Newbie
Posts: 5
Joined: Wed May 31, 2023 9:36 am
Contact:

Is it possible to add an animation when Draggable objects snaps to Droppable?

#1 Post by Wimble »

image_2024-04-14_163609792.png
(746.82 KiB) Not downloaded yet
Basically when one of the ingredients falls into (snaps to center) of the cauldron i want to have a splash animation played over the cauldron.

User avatar
m_from_space
Miko-Class Veteran
Posts: 981
Joined: Sun Feb 21, 2021 3:36 am
Contact:

Re: Is it possible to add an animation when Draggable objects snaps to Droppable?

#2 Post by m_from_space »

Wimble wrote: Sun Apr 14, 2024 9:37 am
image_2024-04-14_163609792.png
Basically when one of the ingredients falls into (snaps to center) of the cauldron i want to have a splash animation played over the cauldron.
There is a callable you can set when a drag finishes its snapping. So if the snap completes, just show a certain screen, or set a variable that then triggers the animation, you know best. Here are the details: https://www.renpy.org/dev-doc/html/drag_drop.html

Code: Select all

screen myscreen():
    drag:
        # ...
        snapped mysnap_func
    
init python:
    def mysnap_func(drag, x, y, completed):
        if completed:
            # trigger the animation here
You may want to check if x and y are the cauldrons snapping coordinates, otherwise this will also trigger when the ingredients snaps to anywhere else. ;)

Code: Select all

# ...
        mydrag.snap(cauldron_x, cauldron_y, 1.0)

if completed and x == couldron_x and y == couldron_y:
    ...

Post Reply

Who is online

Users browsing this forum: Google [Bot]