7.12.2011

Renpy 與 python

renpy可以用'$'或'python:'來插入python的程式碼,
不過注意,不要用來'import' pyhon的library,
否則很容易造成 遊戲存檔失效,
如果要'import'一些額外的library,
請在'init python:'中加入即可。

7.09.2011

Renpy 6.12.1: How do I show a variable in the text?

要怎麼在對話的text中秀出變數,Renpy 官網提供以下三種方法:
$ food = "apple sauce"

"I would like to try some %(food)s, please."
"I would like to try some %s, please." % food
"I would like to try some " + food + ", please."
 不過,我在Renpy 6.12.1試的結果,目前只支援第一種:
"I would like to try some %(food)s, please."

其它兩種,不確定以前有沒有支援,目前看來是不行用的。

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."