8.06.2010

Ren'Py 6.11.0 超新手的圖形化時鐘範例(in windows)

Ren'Py可以加入圖形化時鐘,
可參考:Adding a simple and somewhat functioning Analog Clock(英文)
不過不小修改這個範例 ,直接用這個code在Ren'Py 6.11.0卻不能執行。
所以我把修改後,可以在Ren'Py 6.11.0下執行的code公開,
主要是renpy.image(name,image)需要兩個參數,
其它只是一些小修改。


#script.rpy code 
init python: 
    clock = False
    minutes = 540
    renpy.image("clock","Clock.png") # Short Clockhand
    renpy.image("clock_1","Clock_1.png") # Long Clockhand
    renpy.image("clock_2","Clock_2.png") # Clockface
  
    def Clock():
        if clock: # if False - clock is hide
            ui.at(Position(xpos=150, ypos=140, xanchor="center", yanchor="center"))
            ui.add("clock_2")
            # xalign and yalign can be replaced by xpos and ypos - position where the center of the clock should be
            # this segment is the one responsible for the clockface

            ui.at(Position(xpos=150, ypos=140, xanchor="center", yanchor="center"))
            ui.at(RotoZoom((minutes*6), (minutes*6), 5.0, 1, 1, 1, rot_bounce= False, rot_anim_timebase=False, opaque=False), )
            ui.add("clock")
            # this segment is the one responsible for the short clock hand.

            ui.at(Position(xpos=150, ypos=140, xanchor="center", yanchor="center"))
            ui.at(RotoZoom ((minutes*0.5), (minutes*0.5), 5.0, 1, 1, 1, rot_bounce= False, rot_anim_timebase=False, opaque=False))
            ui.add("clock_1")
            # this segment is the one responsible for the long clock hand.

    config.overlay_functions.append(Clock)



init:
label start:

    $ clock = True
    with dissolve


#End of script.rpy 

另外就是Clock.png, Clock_1.png及Clock_2.png請放在
../renpy-6.11.0/common/
注意圖形檔案及檔名不要錯了哦。