惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Google DeepMind News
Google DeepMind News
Stack Overflow Blog
Stack Overflow Blog
Hugging Face - Blog
Hugging Face - Blog
博客园_首页
T
The Blog of Author Tim Ferriss
博客园 - 叶小钗
N
Netflix TechBlog - Medium
腾讯CDC
C
Check Point Blog
P
Proofpoint News Feed
Engineering at Meta
Engineering at Meta
GbyAI
GbyAI
S
SegmentFault 最新的问题
F
Fortinet All Blogs
美团技术团队
U
Unit 42
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
博客园 - 司徒正美
F
Full Disclosure
Recorded Future
Recorded Future
D
DataBreaches.Net
博客园 - 【当耐特】
Martin Fowler
Martin Fowler
J
Java Code Geeks
I
InfoQ
Y
Y Combinator Blog
A
About on SuperTechFans
AI
AI
爱范儿
爱范儿
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Forbes - Security
Forbes - Security
W
WeLiveSecurity
M
MIT News - Artificial intelligence
雷峰网
雷峰网
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Simon Willison's Weblog
Simon Willison's Weblog
Schneier on Security
Schneier on Security
The GitHub Blog
The GitHub Blog
Security Archives - TechRepublic
Security Archives - TechRepublic
aimingoo的专栏
aimingoo的专栏
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
G
GRAHAM CLULEY
Know Your Adversary
Know Your Adversary
Latest news
Latest news
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
D
Docker
Recent Commits to openclaw:main
Recent Commits to openclaw:main
量子位
V2EX - 技术
V2EX - 技术
Project Zero
Project Zero

博客园 - SeanLin

JSDoc参考注释模板 [转]Git常用操作命令 Cocos2d-html5 HelloWorld模板和引擎使用简介 Javascript API Document生成工具JSDoc HTML5游戏开发涉及到的安全问题 Javascript开发的HTML5游戏的知识产权保护 CCTextureCache的多线程加载原理和使用 引擎demo任务 引擎初始化过程 引擎开发数据记录 游戏引擎消息循环机制 渲染部分 几个需要思考的问题 【转】使用Jasob混淆javascript代码 【转】html5游戏开发引擎大全 【转】V8 Javascript 引擎设计理念 android 字体位置信息 【转】蓝牙协议中HCI层的研究与开发 【转】蓝牙协议的命令和事件
Cocos2d-html5资源预加载列表自动扫描脚本
SeanLin · 2012-08-03 · via 博客园 - SeanLin

Cocos2d-html5引擎资源加载列表的自动产生脚本,已经在捕鱼达人上验证过。

 脚本的使用方法:

1. 将脚本放到res目录下(默认目录名是res,当然你也可以手动替换为其他名字,修改path)

2. 修改输出文件路径和和资源文件夹的目录名

3. 执行脚本,就能自动扫描当前目录和子目录的所有文件,自动判断类型,产生出Cocos2d-html5支持的资源列表到js文件中。

# 1. Change the output file path by yourself 

outputfile=/Users/linshun/work/FishingJoyH5/FishingJoyResource.js

# 2. Specify your resources directory name

path="res"

loopDir(){

for file in find *

do 

if [ -d $file ] 

then 

echo "$file is directory" 

cd ./$file

loopDir

cd ..

elif [ -f $file ]

then

echo "$file is file"

if [ ${file##*.} = "png" -o ${file##*.} = "jpg" ] 

then

#echo "$extension"

echo "{type:\"image\", src:\"$path${PWD##*$path}/$file\"}," >>  $outputfile

elif [ ${file##*.} = "plist" ]

then

echo "{type:\"plist\", src:\"$path${PWD##*$path}/$file\"}," >>  $outputfile

elif [ ${file##*.} = "fnt" ]

then

echo "{type:\"fnt\", src:\"$path${PWD##*$path}/$file\"}," >>  $outputfile

elif [ ${file##*.} = "tga" ]

then

echo "{type:\"tga\", src:\"$path${PWD##*$path}/$file\"}," >>  $outputfile

elif [ ${file##*.} = "tmx" ]

then

echo "{type:\"tmx\", src:"$path${PWD##*$path}"/"$file"}," >>  $outputfile

elif [ ${file##*.} = "mp3" -o ${file##*.} = "ogg" ] 

then

#echo "$extension"

echo "{type:\"effect\", src:"$path${PWD##*$path}"/"$file"}," >>  $outputfile

fi

fi

done

}

# Release the resource array to js file.

echo "var g_ressources = [" >> $outputfile

loopDir 

#echo "{type:\"null\", src:\"null\"}" >>  $outputfile

# remove the last comma

echo "];" >> $outputfile

echo "Finish."

转载请注明:SeanLin,http://www.cnblogs.com/SeanLin/archive/2012/08/03/2621325.html