7.02.2011

Renpy 6.12.1: Drag and Drop

Renpy 6.12.1支援滑鼠托拉(Drag and Drop)的功能,
官網有範例,不過若直接複製貼上範例code,
會發現有些小錯誤:
1. 請將drag_group改成draggroup
2. 去下載圖片,裡面的圖記得改成自己圖片的名稱

修改後範例如下:

init python:

    def detective_dragged(drags, drop):

        if not drop:
            return

        store.detective = drags[0].drag_name
        store.city = drop.drag_name

        return True

screen send_detective_screen:

    # A map as background.
    add "europe.jpg"

    # A drag group ensures that the detectives and the cities.
    draggroup:

        # Our detectives.
        drag:
            drag_name "Ivy"
            child "ivy.png"
            droppable False
            dragged detective_dragged
            xpos 100 ypos 100
        drag:
            drag_name "Zack"
            child "zack.png"
            droppable False
            dragged detective_dragged
            xpos 150 ypos 100

        # The cities they can go to.
        drag:
            drag_name "London"
            child "london.png"
            draggable False
            xpos 450 ypos 140
        drag:
            drag_name "Paris"
            draggable False
            child "paris.png"
            xpos 500 ypos 280

label send_detective:
    "We need to investigate! Who should we send, and where should they go?"

    call screen send_detective_screen

    "Okay, we'll send %(detective)s to %(city)s."

沒有留言:

張貼留言