【cocos2d-js官方文檔】十一、cc.path

來源:互聯網
上載者:User

標籤:cocos2d   cocos2d-js   javascript   html5   遊戲   

概述

該單例是為了方便開發人員操作檔案路徑所設計的。定義為cc.path的目的是為了跟nodejs的path保持一致。裡面定義的api也基本跟nodejs的path模組一致,但不全有,今後可能還會繼續根據需求添加。同時也加了一些path模組沒有的pai,例如cc.path.changeExtname和cc.path.changeBasename。

cc.path.join

路徑拼接操作。

參數:

name type
可變長度的參數 String
cc.path.extname

擷取檔案路徑的尾碼名。

參數:

name type
pathStr String
cc.path.basename

擷取檔案名稱。

參數:

name type remark
pathStr String 必填
extname String 選填,指定擷取的檔案名稱所要去除的尾碼名,不填則認為不去除檔案尾碼名
cc.path.driname

擷取檔案所在檔案夾路徑。

參數:

name type remark
pathStr String 必填,檔案路徑
cc.path.changeExtname

改變檔案尾碼名。

參數:

name type remark
pathStr String 必填
extname String 指定要修改成的尾碼名, 不填是認為不加尾碼名
cc.path.changeBasename

改變檔案名稱。

參數:

name type remark
pathStr String 必填
basename String 指定要修改成的尾碼名, 不填是認為不加尾碼名
isSameExt Boolean 是否保證相同尾碼名
範例

參見tests中的PathTest測試例。

轉載請註明:http://www.cocos2dx.net/post/200

【cocos2d-js官方文檔】十一、cc.path

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.