diff --git a/helloWorld/HelloWorld.tpl b/helloWorld/HelloWorld.tpl new file mode 100644 index 0000000..84bdf8b --- /dev/null +++ b/helloWorld/HelloWorld.tpl @@ -0,0 +1,14 @@ +var HelloWorld = cc.Scene.extend({ + onEnter:function(){ + this._super(); + var winSize = cc.visibleRect; + //从flax输出的素材文件中,创建id为anim的动画,对应flash库中链接名为mc.anim的动画 + //添加到this中,并设置位置为舞台中心 + var anim = flax.assetsManager.createDisplay(res.anim, "helloWorld", {parent: this, x: winSize.width/2, y: winSize.height/2}); + //在最后一帧停住 + anim.autoStopWhenOver = true; + //从当前帧就是第1帧开始播放 + anim.play(); + #code# + } +}); \ No newline at end of file diff --git a/helloWorld/autoUpdate.bat b/helloWorld/autoUpdate.bat new file mode 100644 index 0000000..e59451e --- /dev/null +++ b/helloWorld/autoUpdate.bat @@ -0,0 +1,2 @@ +node autoUpdate.js +cocos run -p web --port 8888 \ No newline at end of file diff --git a/helloWorld/autoUpdate.js b/helloWorld/autoUpdate.js new file mode 100644 index 0000000..cd191de --- /dev/null +++ b/helloWorld/autoUpdate.js @@ -0,0 +1,38 @@ +var fs = require('fs'); +var resTpl=fs.readFileSync("resource.tpl", "utf-8"); +var HelloWorldTpl=fs.readFileSync("HelloWorld.tpl", "utf-8"); +var codeTpl=fs.readFileSync("code.tpl", "utf-8"); +String.prototype.endsWith = function(suffix) { + return this.indexOf(suffix, this.length - suffix.length) !== -1; +}; +function filterJsonOrPlist(str, index, array){ + if(str=="flaxAnim.plist")return false; + if(str.endsWith(".json")||str.endsWith(".plist"))return true; + return false; +} +function getFilenameNoSuffix(str){ + if(str.endsWith(".json"))return str.substr(0,str.length-5); + if(str.endsWith(".plist"))return str.substr(0,str.length-6); + return str; +} +fs.readdir("./res",function(err, files){ + //console.log(files); + var plistFiles=files.filter(filterJsonOrPlist); + console.log(plistFiles); + var res1='',res2='',code=''; + for(var i=0;i