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

推荐订阅源

S
SegmentFault 最新的问题
爱范儿
爱范儿
博客园 - Franky
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
WordPress大学
WordPress大学
宝玉的分享
宝玉的分享
雷峰网
雷峰网
酷 壳 – CoolShell
酷 壳 – CoolShell
IT之家
IT之家
有赞技术团队
有赞技术团队
美团技术团队
Last Week in AI
Last Week in AI
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
大猫的无限游戏
大猫的无限游戏
The Cloudflare Blog
Jina AI
Jina AI
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Engineering at Meta
Engineering at Meta
T
Tailwind CSS Blog
J
Java Code Geeks
Martin Fowler
Martin Fowler
I
InfoQ
小众软件
小众软件
MongoDB | Blog
MongoDB | Blog

博客园 - 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