Drag and drop with image hover effect

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
User avatar
abeplaga
Newbie
Posts: 8
Joined: Mon Oct 15, 2018 10:09 am
Contact:

Drag and drop with image hover effect

#1 Post by abeplaga » Mon Oct 15, 2018 10:40 am

[Warning: I'm not programmer but last week I install Ren'Py and even though I think I've learned a lot, I'm still a newbie :s]

I everyone. I’m trying a drag and drop system with two images: one is the objet to drag and the other the area to drop it.
I want that when cursor hover the image object changes to another image(like a warning of "ey, this is the object to interact!!"), and when it's dragging too. Also, when I'm dragging the object to the drop area the image of area changes too, like a warning of "ey, this is where to put it!!"
Is it posible?

I've read the Drag and Drop Documentation and I think this is the key of what I want:

"A Drag has one child. The child's state reflects the status of the drag and drop operation:

selected_hover - when it is being dragged.
selected_idle - when it can be dropped on.
hover - when the draggable will be dragged when the mouse is clicked.
idle - otherwise."


but I don't know how it's working the child state.

This is my code on screens.rpy (using the code with modifications of the documentation). It's 100% operative but doesn't have the hover :(

Code: Select all

init python:

    def myobject_drag(drags, drop):

        if not drop:
            return

        store.myobject = drags[0].drag_name
        store.myarea = drop.drag_name

        return True

screen send_object_to_area:
    modal True

    draggroup:

        drag:
            drag_name "myobject"
            child "myobject_idle.png"
            droppable False
            dragged myobject_drag
            xpos 288 ypos 593

        drag:
            drag_name "myarea"
            child "myarea_idle.png"
            draggable False
            xpos 1318 ypos 79
With the child line I'm trying everything. Reading the documentation I was thinking it's something like

Code: Select all

 child "myobject_%s.png"

Code: Select all

child selected_idle "myobject_idle.png" selected_hover "myobject_hover.png"
but nothing works :(

If anyone can help me, I'll be eternally grateful. I have searched the forums and have not finded a similar answer so that is why I ask here.

Thank you! And I'm sorry if I don't make myself clear.

philat
Eileen-Class Veteran
Posts: 1451
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: Drag and drop with image hover effect

#2 Post by philat » Mon Oct 15, 2018 11:06 am

You were close.

Code: Select all

drag:
    idle_child "idle.png"
    hover_child "hover.png"

User avatar
abeplaga
Newbie
Posts: 8
Joined: Mon Oct 15, 2018 10:09 am
Contact:

Re: Drag and drop with image hover effect

#3 Post by abeplaga » Mon Oct 15, 2018 12:45 pm

philat wrote:
Mon Oct 15, 2018 11:06 am
You were close.

Code: Select all

drag:
    idle_child "idle.png"
    hover_child "hover.png"
Thank you! With selected_idle_child "myarea_hover.png" now it's working ^^

Post Reply

Who is online

Users browsing this forum: No registered users