HTML5 遊戲開發框架——LimeJS

         本文介紹如何在Windows平臺下載LimeJS。LimeJS的官網地址爲http://www.limejs.com/,可以在此下載到LimeJS的壓縮包。將其解壓後,進入bin子目錄,裏面有個lime.py文件,這是一個Python腳本,毫無疑問要安裝一個Python解釋器了。我下載並安裝的Python版本是3.2。

         然後打開一個CMD命令提示符,改變當前目錄至LimeJS的bin子目錄下,運行lime.py init命令,輸出爲Lime requires git. Get it from http://git-scm.com/download。git是一個分佈式的版本控制系統,lime需要用它下載Closure Library、Box2D、Closure compiler和Closure Templates。既然是在windows平臺,下個windows版的git安裝程序就是了。

        將git安裝好以後,需要能夠在CMD命令提示符下運行它,方法是將git.exe所在的目錄添加至環境變量PATH中(git.exe一般在C:\Program Files\Git\bin目錄下)。配置好git後,再次運行lime.py init,所有的軟件包都已正確下載,但在更新的時候卻出現瞭如下錯誤:

Updating Closure deps file

digitalfruit-limejs-e5e49e0\closure\closure/goog/deps.js"

Traceback (most recent call last):

  File "digitalfruit-limejs-e5e49e0\closure\closure\bin\build\depswriter.py", line 206, in <module> main()

  File "digitalfruit-limejs-e5e49e0\closure\closure\bin\build\depswriter.py", line 182, in main

    path_to_source.update(_GetRelativePathToSourceDict(root, prefix=prefix))

  File "digitalfruit-limejs-e5e49e0\closure\closure\bin\build\depswriter.py", line 149, in _GetRelativePathToSourceDict

    path_to_source[prefixed_path] = source.Source(source.GetFileContents(path))

  File "digitalfruit-limejs-e5e49e0\closure\closure\bin\build\source.py", line 98, in GetFileContents

    return fileobj.read()

UnicodeDecodeError: 'gbk' codec can't decode bytes in position 8291-8292: illegal multibyte sequence

        對於這個錯誤,網上已經有人給出瞭解決辦法。具體地,首先定位到limeJS\closure\closure\bin\build目錄,裏面有兩個文件:source.py和depswriter.py。在source.py中找到fileobj = open(path)這一行(接近文件末尾處),將其替換爲fileobj = open(path, encoding=’utf-8’)。然後在depswriter.py中找到paths = source_map.keys()這一行(一般在51行),將其替換爲paths = list(source_map.keys())。

經過上面的修改, lime.py init就可以正常運行了。

 

附:

1.       Closure Tools

          Closure工具包括:

          JavaScript優化器:移除不需要的代碼,壓縮其餘的代碼以實現速度最大化;   

          與Firebug協同工作的Firefox擴展Closure Inspector,目的是簡化調試;   

          Closure compiler:能以命令行、Web應用或Firefox擴展形式運行;   

          Closure Library:Google的標準JavaScript類庫;   

          Closure Templates:提供了一組預編譯的JavaScript接口組件。

2.       Box2D

          一個很有名的2D物理遊戲引擎。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章