{"id":5774,"date":"2025-08-09T00:26:15","date_gmt":"2025-08-08T16:26:15","guid":{"rendered":"https:\/\/7gugu.com\/?p=5774"},"modified":"2025-08-25T15:31:57","modified_gmt":"2025-08-25T07:31:57","slug":"cocos-2-x%e5%a6%82%e4%bd%95%e9%80%9a%e8%bf%87%e5%91%bd%e4%bb%a4%e8%a1%8c%e6%8c%87%e5%ae%9a%e8%87%aa%e5%ae%9a%e4%b9%89%e5%bc%95%e6%93%8e%e8%b7%af%e5%be%84","status":"publish","type":"post","link":"https:\/\/7gugu.com\/index.php\/2025\/08\/09\/cocos-2-x%e5%a6%82%e4%bd%95%e9%80%9a%e8%bf%87%e5%91%bd%e4%bb%a4%e8%a1%8c%e6%8c%87%e5%ae%9a%e8%87%aa%e5%ae%9a%e4%b9%89%e5%bc%95%e6%93%8e%e8%b7%af%e5%be%84\/","title":{"rendered":"Cocos 2.X\/2.4\u5982\u4f55\u901a\u8fc7\u547d\u4ee4\u884c\u6307\u5b9a\u81ea\u5b9a\u4e49\u5f15\u64ce\u8def\u5f84"},"content":{"rendered":"\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>\u6700\u8fd1\u8f6c\u578b\u6210\u4e86\u65e0\u60c5\u7684\u6d41\u6c34\u7ebf\u5de5\u7a0b\u5e08\uff0c\u5929\u5929\u5c31\u662f\u5e2e\u7ec4\u91cc\u7684\u540c\u4e8b\u7f16\u5199\u6784\u5efa\u6d41\u6c34\u7ebf\u3002<\/p>\n<\/blockquote>\n\n\n\n<h2 class=\"wp-block-heading\">\u9700\u6c42<\/h2>\n\n\n\n<p>\u76ee\u524d\u6709\u4e2a\u9700\u6c42\u5c31\u662f\u5e0c\u671b\u53ef\u4ee5\u5728\u6d41\u6c34\u7ebf\u6784\u5efa\u7684\u8fc7\u7a0b\u4e2d\uff0c\u6307\u5b9a\u81ea\u5b9a\u4e49\u8def\u5f84\u7684\u5f15\u64ce\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u56f0\u5883<\/h2>\n\n\n\n<p>\u7ffb\u904d\u4e86\u6574\u4e2aCocos\u6587\u6863\u548c\u8bba\u575b\uff0c\u5728Google\u4e0a\u627e\u4e862-3\u4e2a\u6708\u90fd\u6ca1\u627e\u52302.X\u7684\u9879\u76ee\uff0c\u7a76\u7adf\u8981\u600e\u4e48\u6837\u624d\u80fd\u5728\u547d\u4ee4\u884c\u6784\u5efa\u7684\u65f6\u5019\u6307\u5b9a\u81ea\u5b9a\u4e49\u5f15\u64ce\u8def\u5f84\u30023.X\u5b98\u65b9\u5012\u662f\u7ed9\u547d\u4ee4\u884c\u65b0\u589e\u4e86\u53c2\u6570\uff0c\u7528\u4e8e\u6307\u5b9a\u81ea\u5b9a\u4e49\u5f15\u64ce\u7684\u4f4d\u7f6e\u3002<\/p>\n\n\n\n<p>3.x\u53ef\u4ee5\u901a\u8fc7&#8211;engine\u53c2\u6570\u6765\u624b\u52a8\u6307\u5b9a\u5f15\u64ce\u8def\u5f84 <a href=\"https:\/\/docs.cocos.com\/creator\/3.8\/manual\/zh\/editor\/publish\/publish-in-command-line.html\">https:\/\/docs.cocos.com\/creator\/3.8\/manual\/zh\/editor\/publish\/publish-in-command-line.html<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u89e3\u51b3<\/h2>\n\n\n\n<p>\u4eca\u5929\u5728\u7ffb\u770b\u5b9a\u5236\u5316\u5f15\u64ce\u7684\u65f6\u5019\uff0c\u5076\u7136\u53d1\u73b0\u4e86\u8fd9\u4e2a\u6280\u5de7\uff0c\u8d85\u7ea7\u65e0\u654c\u7b80\u5355\u3002\u5c31\u662f\u5728\u9879\u76ee\u7684\u6839\u76ee\u5f55\u4e0b\u521b\u5efa\u4e00\u4e2alocal\u6587\u4ef6\u5939\uff0c\u7136\u540e\u5728\u91cc\u9762\u8bbe\u7f6e\u4e00\u4e2asettings.json\uff0c\u5c31\u53ef\u4ee5\u8f7b\u677e\u6307\u5b9a\u9879\u76ee\u6240\u4f7f\u7528\u7684\u81ea\u5b9a\u4e49\u5f15\u64ce\u8def\u5f84\u4e86\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img data-dominant-color=\"f4f6f8\" data-has-transparency=\"false\" style=\"--dominant-color: #f4f6f8;\" loading=\"lazy\" decoding=\"async\" width=\"430\" height=\"175\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" src=\"https:\/\/7gugu.com\/wp-content\/uploads\/2025\/08\/\u56fe\u7247.png\" alt=\"\" class=\"wp-image-5784 not-transparent\" srcset=\"https:\/\/7gugu.com\/wp-content\/uploads\/2025\/08\/\u56fe\u7247.png 430w, https:\/\/7gugu.com\/wp-content\/uploads\/2025\/08\/\u56fe\u7247-300x122.png 300w\" \/><\/figure>\n\n\n\n<p>\u6211\u8fd9\u91cc\u8fd8\u5199\u4e86\u4e2anodejs\u7684\u811a\u672c\u6765\u8f85\u52a9\u521b\u5efa\uff0c\u5206\u4eab\u7ed9\u5927\u5bb6\u4f7f\u7528\uff1a<\/p>\n\n\n\n<p>\u4fdd\u5b58\u4e3acustomEnginePath.js<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\nconst fs = require(&#039;fs&#039;);\nconst path = require(&#039;path&#039;);\n\n\/\/ Parse command line arguments\nconst args = process.argv.slice(2);\nlet customEnginePath = null;\n\n\/\/ Parse --path argument\nfor (let i = 0; i &lt; args.length; i++) {\n    if (args&#x5B;i] === &#039;--path&#039; &amp;&amp; i + 1 &lt; args.length) {\n        customEnginePath = args&#x5B;i + 1];\n        break;\n    }\n}\n\n\/\/ Get current working directory absolute path\nconst currentDir = process.cwd();\n\nif (!customEnginePath) {\n  console.error(&#039;\u274c Custom engine path required!&#039;);\n}\n\n\/\/ Build engine path - use custom path if provided, otherwise use default\nconst enginePath = path.resolve(customEnginePath);\n\n\/\/ settings.json file path\nconst settingsPath = path.join(currentDir, &#039;local&#039;, &#039;settings.json&#039;);\n\ntry {\n    \/\/ Ensure local directory exists\n    const localDir = path.dirname(settingsPath);\n    if (!fs.existsSync(localDir)) {\n        fs.mkdirSync(localDir, { recursive: true });\n        console.log(&#039;\ud83d\udcc1 Created local directory&#039;);\n    }\n    \n    \/\/ Create complete settings configuration object\n    const settings = {\n        &quot;use-global-engine-setting&quot;: false,\n        &quot;use-default-js-engine&quot;: false,\n        &quot;js-engine-path&quot;: enginePath,\n        &quot;use-default-cpp-engine&quot;: true,\n        &quot;cpp-engine-path&quot;: &quot;&quot;\n    };\n    \n    \/\/ Write configuration to file with beautiful formatting\n    const settingsContent = JSON.stringify(settings, null, 2);\n    fs.writeFileSync(settingsPath, settingsContent, &#039;utf8&#039;);\n    \n    console.log(&#039;\u2705 Successfully generated\/updated local\/settings.json&#039;);\n    console.log(`\ud83d\udcc1 js-engine-path set to: ${enginePath}`);\n\n    console.log(&#039;\ud83c\udfaf Using custom engine path specified via --path argument&#039;);\n    \n    \/\/ Show whether file was newly created\n    if (!fs.existsSync(settingsPath)) {\n        console.log(&#039;\ud83c\udd95 Created new settings.json file&#039;);\n    } else {\n        console.log(&#039;\ud83d\udd04 Updated existing settings.json file&#039;);\n    }\n    \n} catch (error) {\n    console.error(&#039;\u274c Operation failed:&#039;, error.message);\n    console.log(&#039;\ud83d\udca1 Please check file permissions or disk space&#039;);\n} \n<\/pre><\/div>\n\n\n<p>\u4f7f\u7528\u65b9\u6cd5\uff1a<\/p>\n\n\n\n<p>\u5728\u9879\u76ee\u6839\u76ee\u5f55\u4e0b\u8fd0\u884c\u8fd9\u4e2a\u811a\u672c<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nnode customEnginePath.js --path=&lt;Your Custom Engine Path&gt;\n<\/pre><\/div>\n\n\n<p>\u4f7f\u7528CocosCreator\u6784\u5efa\u7684\u65f6\u5019\uff0c\u5c31\u4f1a\u81ea\u52a8\u4f7f\u7528\u4f60\u6307\u5b9a\u7684\u5f15\u64ce\u8fdb\u884c\u6784\u5efa\u3002<\/p>\n\n\n\n<p>CocosCreator\u5185\u770b\u4e0d\u5230\u8fd9\u4e2a\u8bbe\u7f6e\u662f\u6b63\u5e38\u7684\uff0c\u6784\u5efa\u7684\u65f6\u5019\u662f\u4f1a\u4f7f\u7528\u81ea\u5b9a\u4e49\u5f15\u64ce\u8fdb\u884c\u6784\u5efa\u7684\u3002<\/p>\n\n\n\n<p>\u5982\u679c\u8fd0\u884c\u5b8c\u811a\u672c\uff0c\u4f46\u662fCreator\u5185\u6784\u5efa\u7684\u65f6\u5019\u4f1a\u63d0\u793a\u201cThe first argument muse be of type string or an instance of buffer xxxx\u201d\u7684\uff0c\u5c31\u662fCreator\u7684bug\uff0c\u8981\u624b\u52a8\u8fdb\u81ea\u5b9a\u4e49\u5f15\u64ce\u7684\u9762\u677f\uff0c\u52fe\u9009\u4e00\u4e0b\u5168\u5c40JS\u5f15\u64ce\uff0c\u7136\u540e\u518d\u53d6\u6d88\u52fe\u9009\u5168\u5c40JS\u5f15\u64ce\uff0c\u8fd9\u6837\u5b50Creator\u5185\u6784\u5efa\u624d\u4e0d\u4f1a\u62a5\u9519\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6700\u8fd1\u8f6c\u578b\u6210\u4e86\u65e0\u60c5\u7684\u6d41\u6c34\u7ebf\u5de5\u7a0b\u5e08\uff0c\u5929\u5929\u5c31\u662f\u5e2e\u7ec4\u91cc\u7684\u540c\u4e8b\u7f16\u5199\u6784\u5efa\u6d41\u6c34\u7ebf\u3002 \u9700\u6c42 \u76ee\u524d\u6709\u4e2a\u9700\u6c42\u5c31\u662f\u5e0c\u671b\u53ef\u4ee5\u5728\u6d41\u6c34\u7ebf\u6784 &hellip; <a href=\"https:\/\/7gugu.com\/index.php\/2025\/08\/09\/cocos-2-x%e5%a6%82%e4%bd%95%e9%80%9a%e8%bf%87%e5%91%bd%e4%bb%a4%e8%a1%8c%e6%8c%87%e5%ae%9a%e8%87%aa%e5%ae%9a%e4%b9%89%e5%bc%95%e6%93%8e%e8%b7%af%e5%be%84\/\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">\u201cCocos 2.X\/2.4\u5982\u4f55\u901a\u8fc7\u547d\u4ee4\u884c\u6307\u5b9a\u81ea\u5b9a\u4e49\u5f15\u64ce\u8def\u5f84\u201d<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[29,13],"tags":[],"class_list":["post-5774","post","type-post","status-publish","format-standard","hentry","category-29","category-13"],"_links":{"self":[{"href":"https:\/\/7gugu.com\/index.php\/wp-json\/wp\/v2\/posts\/5774","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/7gugu.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/7gugu.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/7gugu.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/7gugu.com\/index.php\/wp-json\/wp\/v2\/comments?post=5774"}],"version-history":[{"count":6,"href":"https:\/\/7gugu.com\/index.php\/wp-json\/wp\/v2\/posts\/5774\/revisions"}],"predecessor-version":[{"id":5822,"href":"https:\/\/7gugu.com\/index.php\/wp-json\/wp\/v2\/posts\/5774\/revisions\/5822"}],"wp:attachment":[{"href":"https:\/\/7gugu.com\/index.php\/wp-json\/wp\/v2\/media?parent=5774"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/7gugu.com\/index.php\/wp-json\/wp\/v2\/categories?post=5774"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/7gugu.com\/index.php\/wp-json\/wp\/v2\/tags?post=5774"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}