{"id":406,"date":"2018-03-09T18:21:28","date_gmt":"2018-03-09T10:21:28","guid":{"rendered":"http:\/\/blog.xrhoujie.com\/?p=406"},"modified":"2019-01-18T18:40:04","modified_gmt":"2019-01-18T10:40:04","slug":"cocos-creator%e6%80%a7%e8%83%bd%e4%bc%98%e5%8c%96%e4%b8%8e%e5%ba%95%e5%b1%82%e9%83%a8%e7%bd%b2%e6%96%b9%e6%a1%88%e8%a7%a3%e6%9e%90%e4%b8%80","status":"publish","type":"post","link":"http:\/\/blog.xrhoujie.com\/?p=406","title":{"rendered":"Cocos Creator\u6027\u80fd\u4f18\u5316\u4e0e\u5e95\u5c42\u90e8\u7f72\u65b9\u6848\u89e3\u6790(\u4e00)"},"content":{"rendered":"<p>\u5199\u8fd9\u7bc7\u6587\u7ae0\u65f6\u5019\u611f\u89c9\u81ea\u5df1\u624b\u6296,\u6015\u5404\u4f4d\u5927\u4f6c\u55b7\u6211\uff0c\u54c8\u54c8 \u4eca\u5929\u5206\u4eab\u4e00\u4e9b\u4e2a\u4eba\u7684\u5173\u4e8ecocos \u6027\u80fd\u4f18\u5316\u5904\u7406\u65b9\u6848\u3002<\/p>\n<h1 id=\"\u5b9a\u5236\u9879\u76ee\u6784\u5efa\u6a21\u677f\">\u5b9a\u5236\u9879\u76ee\u6784\u5efa\u6a21\u677f<\/h1>\n<p>Creator \u652f\u6301\u5bf9\u6bcf\u4e2a\u9879\u76ee\u5206\u522b\u5b9a\u5236\u6784\u5efa\u6a21\u677f\uff0c\u53ea\u9700\u8981\u5728\u9700\u8981\u5b9a\u5236\u7684\u9879\u76ee\u8def\u5f84\u4e0b\u6dfb\u52a0\u4e00\u4e2a\u00a0<code>build-templates<\/code>\u76ee\u5f55\uff0c\u91cc\u9762\u6309\u7167\u5e73\u53f0\u8def\u5f84\u5212\u5206\u5b50\u76ee\u5f55\uff0c\u7136\u540e\u91cc\u9762\u7684\u6240\u6709\u6587\u4ef6\u5728\u6784\u5efa\u7ed3\u675f\u540e\u90fd\u4f1a\u81ea\u52a8\u6309\u7167\u5bf9\u5e94\u7684\u76ee\u5f55\u7ed3\u6784\u590d\u5236\u5230\u6784\u5efa\u51fa\u7684\u5de5\u7a0b\u91cc\u3002<\/p>\n<p>\u7ed3\u6784\u7c7b\u4f3c\uff1a<\/p>\n<pre><code>project-folder\r\n |--assets\r\n |--build\r\n |--build-templates\r\n      |--web-mobile\r\n            |--index.html\r\n      |--jsb-binary\r\n            |--main.js\r\n      |--jsb-default\r\n            |--main.js\r\n<\/code><\/pre>\n<p>\u8fd9\u6837\u5982\u679c\u5f53\u524d\u6784\u5efa\u7684\u5e73\u53f0\u662f\u00a0<code>web-mobile<\/code>\u00a0\u7684\u8bdd\uff0c\u90a3\u4e48\u00a0<code>build-templates\/web-mobile\/index.html<\/code>\u00a0\u5c31\u4f1a\u5728\u6784\u5efa\u540e\u88ab\u62f7\u8d1d\u5230\u00a0<code>build\/web-mobile\/index.html<\/code>\u3002<\/p>\n<p>\u5b98\u65b9\u7684\u5165\u53e3\u5730\u5740\uff1ahttp:\/\/docs.cocos.com\/creator\/manual\/zh\/publish\/custom-project-build-template.html<\/p>\n<p>\u8fd8\u6709\u4e2a\u571f\u6cd5\u5b50\uff0c\u6211\u4eec\u53ef\u4ee5\u770b\u5230cocos\u6253\u5305\u540e\u7684\u76ee\u5f55\u7ed3\u6784<\/p>\n<p><img loading=\"lazy\" class=\"alignnone size-medium wp-image-407\" src=\"http:\/\/blog.xrhoujie.com\/wp-content\/uploads\/2018\/03\/1-300x152.jpg\" alt=\"\" width=\"300\" height=\"152\" srcset=\"http:\/\/blog.xrhoujie.com\/wp-content\/uploads\/2018\/03\/1-300x152.jpg 300w, http:\/\/blog.xrhoujie.com\/wp-content\/uploads\/2018\/03\/1-768x388.jpg 768w, http:\/\/blog.xrhoujie.com\/wp-content\/uploads\/2018\/03\/1-1024x518.jpg 1024w, http:\/\/blog.xrhoujie.com\/wp-content\/uploads\/2018\/03\/1.jpg 1626w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/p>\n<p>\u76f4\u63a5\u901a\u8fc7js\u64cd\u4f5c\u8fd9\u91cc\u9762\u7684\u5bf9\u5e94id\u4e5f\u53ef\u4ee5\uff0c\u4e0d\u8fc7\u8fd9\u6837\u7684\u8bdd\u6548\u7387\u6709\u4e9b\u4f4e\u6548\uff0c\u80fd\u53d8\u5f97\u6bd4\u5982\u8fdb\u5ea6\u6761\u7684\u80cc\u666f\uff0c\u8fdb\u5ea6\u6761\u7684\u6837\u5f0f\u7b49\u7b49\u3002\u3002\u3002\u3002\u3002\u3002<\/p>\n<h3 id=\"articleHeader1\"><strong>2. \u56fe\u7247\u90e8\u7f72\u81ea\u52a8\u5316\u538b\u7f29\u4f18\u5316<\/strong><\/h3>\n<p>\u6709\u6761\u4ef6\u7684\u540c\u5b66\u76f4\u63a5\u7528gulp\u65b9\u5f0f\u81ea\u52a8\u538b\u7f29\uff0c\u4ee3\u7801\u5982\u4e0b\uff0c<\/p>\n<pre class=\"hljs javascript\"><code><span class=\"hljs-keyword\">var<\/span> imagemin = <span class=\"hljs-built_in\">require<\/span>(<span class=\"hljs-string\">\"gulp-imagemin\"<\/span>);\r\ngulp.task(<span class=\"hljs-string\">\"imagemin\"<\/span>, <span class=\"hljs-function\"><span class=\"hljs-keyword\">function<\/span> (<span class=\"hljs-params\">cb<\/span>) <\/span>{\r\n    gulp.src([<span class=\"hljs-string\">\".\/build\/web-mobile\/**\/*.png\"<\/span>])\r\n        .pipe(imagemin([\r\n            imagemin.gifsicle({<span class=\"hljs-attr\">interlaced<\/span>: <span class=\"hljs-literal\">true<\/span>}),\r\n            imagemin.jpegtran({<span class=\"hljs-attr\">progressive<\/span>: <span class=\"hljs-literal\">true<\/span>}),\r\n            imagemin.optipng({<span class=\"hljs-attr\">optimizationLevel<\/span>: <span class=\"hljs-number\">5<\/span>})\r\n        ]))\r\n        .pipe(gulp.dest(<span class=\"hljs-string\">\".\/build\/web-mobile\/\"<\/span>))\r\n        .on(<span class=\"hljs-string\">\"end\"<\/span>, cb);\r\n});<span class=\"hljs-string\">`<\/span><\/code><\/pre>\n<h6>\u6216\u8005\u76f4\u63a5\u53bb\u718a\u732b\u7f51\u00a0https:\/\/tinypng.com\/<\/h6>\n<p>\u8fdb\u884c\u624b\u52a8\u538b\u7f29<\/p>\n<p>&nbsp;<\/p>\n<h3 id=\"articleHeader2\"><strong>3. \u5bf9\u8c61\u6c60\u4e0e\u573a\u666f\u9500\u6bc1\u5904\u7406\u3002<\/strong><\/h3>\n<h3 id=\"articleHeader2\"><strong>4. \u51cf\u5c11\u9f99\u9aa8\u7f51\u683c\u4e0e\u6ee4\u955c\u7684\u53d8\u5316\u3002<\/strong><\/h3>\n<h3 id=\"articleHeader2\"><strong>5. \u810f\u77e9\u5f62\u68c0\u6d4b\u5904\u7406\u3002<\/strong><\/h3>\n<h3 id=\"articleHeader2\"><strong>6. \u4f4d\u56fe\u5b57\u4f53\u7684\u77e9\u9635\u5f0f\u5904\u7406\u3002<\/strong><\/h3>\n<h3 id=\"articleHeader2\"><strong>7. \u987a\u5e8f\u6267\u884c\uff0c\u540c\u6b65\u6267\u884c\uff0c\u5f02\u6b65\u6267\u884c\u5904\u7406\u65b9\u6848\u3002<\/strong><\/h3>\n<h3 id=\"articleHeader2\"><strong>8. png\u56fe\u7247\u7684\u88c1\u5207\u821e\u53f0\u6e32\u67d3\u4e0e\u4f18\u5316\u5904\u7406\u3002<\/strong><\/h3>\n<h3 id=\"articleHeader2\"><strong>9.cdn\u5904\u7406\u65b9\u6848\u3002<\/strong><\/h3>\n<h3 id=\"articleHeader2\"><strong>10. \u6587\u4ef6\u8d44\u6e90\u589e\u52a0\u4e0emd5\u5f3a\u7f13\u5b58\u9002\u914d\u5904\u7406\u3002<\/strong><\/h3>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5199\u8fd9\u7bc7\u6587\u7ae0\u65f6\u5019\u611f\u89c9\u81ea\u5df1\u624b\u6296,\u6015\u5404\u4f4d\u5927\u4f6c\u55b7\u6211\uff0c\u54c8\u54c8 \u4eca\u5929\u5206\u4eab\u4e00\u4e9b\u4e2a\u4eba\u7684\u5173\u4e8ecocos \u6027\u80fd\u4f18\u5316\u5904\u7406\u65b9\u6848\u3002 \u5b9a\u5236\u9879 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[30],"tags":[],"_links":{"self":[{"href":"http:\/\/blog.xrhoujie.com\/index.php?rest_route=\/wp\/v2\/posts\/406"}],"collection":[{"href":"http:\/\/blog.xrhoujie.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/blog.xrhoujie.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/blog.xrhoujie.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/blog.xrhoujie.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=406"}],"version-history":[{"count":1,"href":"http:\/\/blog.xrhoujie.com\/index.php?rest_route=\/wp\/v2\/posts\/406\/revisions"}],"predecessor-version":[{"id":409,"href":"http:\/\/blog.xrhoujie.com\/index.php?rest_route=\/wp\/v2\/posts\/406\/revisions\/409"}],"wp:attachment":[{"href":"http:\/\/blog.xrhoujie.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=406"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/blog.xrhoujie.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=406"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/blog.xrhoujie.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=406"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}