Commit 5cb77a3c authored by Tt's avatar Tt

1

parent dec51142
{
"ver": "1.1.2",
"uuid": "c35bb2f6-f24a-4850-ae44-643f2fdc7541",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {
"ios": false,
"android": false
},
"subMetas": {}
}
\ No newline at end of file
{"ver":"1.1.2","uuid":"c35bb2f6-f24a-4850-ae44-643f2fdc7541","isBundle":false,"bundleName":"","priority":1,"compressionType":{},"optimizeHotUpdate":{},"inlineSpriteFrames":{},"isRemoteBundle":{"ios":false,"android":false},"subMetas":{}}
\ No newline at end of file
This diff is collapsed.
......@@ -4,33 +4,37 @@ import pg from "./pg";
import map from "./map";
const { ccclass, property } = cc._decorator;
enum CELLTYPE {
SPEAK = 1,
MOVE_ADD = 2,
ROLL_AGAIN = 3,
DELAY_TIME = 4,
JUMP_ROLL = 5,
WIN = 100,
const CELLTYPE = {
SPEAK: 1,
MOVE_ADD: 2,
ROLL_AGAIN: 3,
DELAY_TIME: 4,
JUMP_ROLL: 5,
WIN: 100,
}
@ccclass
export default class SceneComponent extends MyCocosSceneComponent {
export default class NewClass extends MyCocosSceneComponent {
addPreloadImage() {
this.log("test addPreloadImage")
// TODO 根据自己的配置预加载图片资源
this._imageResList.push({ url: this.data.pic_url });
this._imageResList.push({ url: this.data.pic_url_2 });
this.data && this._imageResList.push({ url: this.data.pic_url });
this.data && this._imageResList.push({ url: this.data.pic_url_2 });
}
addPreloadAudio() {
this.log("test addPreloadAudio")
// TODO 根据自己的配置预加载音频资源
this._audioResList.push({ url: this.data.audio_url });
this.data && this._audioResList.push({ url: this.data.audio_url });
}
addPreloadAnima() {
this.log("test addPreloadAnima")
}
onLoadEnd() {
this.log("test onLoadEnd")
// TODO 加载完成后的逻辑写在这里, 下面的代码仅供参考
this.initData();
this.initView();
......@@ -39,35 +43,17 @@ export default class SceneComponent extends MyCocosSceneComponent {
_cantouch = null;
initData() {
this.log("test initData")
// 所有全局变量 默认都是null
this._cantouch = true;
}
//开发流程
//1.start状态
//2.开局效果
//3.骰子动效,stop效果。
//4.星星位移。
//--游戏开始就计算好后续的所有点数数组。
//--骰子及位移点数等添加到一个数组中,每次需要获取当前点和目标点时进行实时获取。
//--出现错误反向退回。
//--位移停止后触发目的地内容。
//5.触发目的地道具效果。
//--如各类道具,进行分类。统一调用一个方法输入,给予id
//--如:终点。可触发终点效果。
//--如:语音。触发语音效果。
//--如:加速。触发位移效果。
//6.语音录音部分。
//--动画组件,start end。
//7.机器人骰子及自动进程。
//--机器人难度处理,游戏开始就计算好后续的所有点数数组。
//--调用通用的内容进行位移。
//8.结算胜负
//9.重新开始
initView() {
this.log("test initView")
this.initTouzi();
this.initChess();
}
initEvent() {
this.log("test initEvent")
pg.event.on("game_start", () => { this.onGameStart() })
pg.event.on("speak_success", () => { this.onSpeakScueess() });
......@@ -245,16 +231,16 @@ export default class SceneComponent extends MyCocosSceneComponent {
let touzi = icon.getComponent("touzi");
let hand = pg.view.find(touzi_ani, "hand");
let btn_stop = pg.view.find(touzi_ani, "btn_stop");
btn_stop.active = false;
pg.view.visible(btn_stop, false);
this.lastPointId = this.playerPoint + 1;
if (!runNum) {
runNum = 1 + Math.floor(Math.random() * 6);
if (this.turnRobot) runNum = 1 + Math.floor(Math.random() * 5);
}
hand.active = false;
pg.view.visible(hand, false);
clearTimeout(this.stopHandTimer);
touzi.stopAni(runNum).then(() => {
touzi_ani.active = false;
pg.view.visible(touzi_ani, false);
pg.event.emit("player_point_update", { isRobot: this.turnRobot, num: runNum });
this.moveChess(runNum).then(() => {
this.checkCell();
......@@ -269,8 +255,8 @@ export default class SceneComponent extends MyCocosSceneComponent {
let touzi = icon.getComponent("touzi");
let hand = pg.view.find(touzi_ani, "hand");
let btn_stop = pg.view.find(touzi_ani, "btn_stop");
btn_stop.active = true;
touzi_ani.active = true;
pg.view.visible(btn_stop, true);
pg.view.visible(touzi_ani, true);
touzi.startAni();
if (this.turnRobot) {
setTimeout(() => {
......@@ -278,7 +264,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
}, 300 + Math.random() * 200);
} else {
this.stopHandTimer = setTimeout(() => {
hand.active = true;
pg.view.visible(hand, true);
}, 5000);
}
pg.hw.playLocalAudio("touzi", true).then((id: number) => {
......
{
"ver": "1.0.8",
"uuid": "408a67f8-65fa-4cf1-8cf2-83e20e1a0fd5",
"uuid": "7091890a-4097-4c74-b388-e0be538f9c1c",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
......
This diff is collapsed.
{
"ver": "1.0.8",
"uuid": "408a67f8-65fa-4cf1-8cf2-83e20e1a0fd5",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
......@@ -23,21 +23,11 @@ export default class NewClass extends cc.Component {
this.count = 0;
}
start() {
}
update(dt) {
this.count++;
// if (this.count >= 30) this.count = 0;
this.updateItems();
}
updateItems() {
let cur = Math.floor(this.count / 30) % 4
for (let i = 0; i < 4; i++) {
let item = pg.view.find(this, "btn_audio" + i);
item.active = cur == i;
}
}
}
{
"ver": "1.0.8",
"uuid": "bed01784-8114-4d5e-bd26-36345307676c",
"uuid": "764039ec-62e7-416b-a01b-1f8dd451a870",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
......
......@@ -59,9 +59,5 @@ export default class NewClass extends cc.Component {
});
return posArray;
}
start() {
}
// update (dt) {}
}
......@@ -22,12 +22,19 @@ export default class NewClass extends cc.Component {
this.showAni();
}
showAni() {
this.node.x += 400;
this.node.y -= 200;
cc.tween(this.node).by(0.3, { x: -400, y: 200 }).start();
setTimeout(() => {
this.showAni();
}, 2000);
if (this.node && this.node.active) {
this.node.x += 400;
this.node.y -= 200;
cc.tween(this.node).by(0.3, { x: -400, y: 200 }).call(() => {
setTimeout(() => {
this.showAni();
}, 1500);
}).start();
} else {
setTimeout(() => {
this.showAni();
}, 100);
}
}
update(dt) {
......
export default [
{ "id": "1", "yellow_x": "-480", "yellow_y": "70", "blue_x": "-345", "blue_y": "70", "type": "0", "value": "0" }, { "id": "2", "yellow_x": "-480", "yellow_y": "290", "blue_x": "-345", "blue_y": "135", "type": "1", "value": "blackboard" }, { "id": "3", "yellow_x": "-270", "yellow_y": "290", "blue_x": "-270", "blue_y": "135", "type": "1", "value": "window" }, { "id": "4", "yellow_x": "-130", "yellow_y": "290", "blue_x": "-130", "blue_y": "135", "type": "1", "value": "door" }, { "id": "5", "yellow_x": "-10", "yellow_y": "290", "blue_x": "-10", "blue_y": "135", "type": "2", "value": "2" }, { "id": "6", "yellow_x": "150", "yellow_y": "290", "blue_x": "150", "blue_y": "135", "type": "1", "value": "window" }, { "id": "7", "yellow_x": "300", "yellow_y": "290", "blue_x": "300", "blue_y": "135", "type": "5", "value": "14" }, { "id": "8", "yellow_x": "500", "yellow_y": "290", "blue_x": "370", "blue_y": "135", "type": "1", "value": "door" }, { "id": "9", "yellow_x": "500", "yellow_y": "70", "blue_x": "370", "blue_y": "70", "type": "3", "value": "1" }, { "id": "10", "yellow_x": "500", "yellow_y": "-70", "blue_x": "370", "blue_y": "-70", "type": "1", "value": "door" }, { "id": "11", "yellow_x": "500", "yellow_y": "-280", "blue_x": "370", "blue_y": "-125", "type": "1", "value": "blackboard" }, { "id": "12", "yellow_x": "290", "yellow_y": "-280", "blue_x": "290", "blue_y": "-125", "type": "1", "value": "window" }, { "id": "13", "yellow_x": "150", "yellow_y": "-280", "blue_x": "150", "blue_y": "-125", "type": "2", "value": "3" }, { "id": "14", "yellow_x": "10", "yellow_y": "-280", "blue_x": "10", "blue_y": "-125", "type": "1", "value": "blackboard" }, { "id": "15", "yellow_x": "-130", "yellow_y": "-280", "blue_x": "-130", "blue_y": "-125", "type": "2", "value": "1" }, { "id": "16", "yellow_x": "-270", "yellow_y": "-280", "blue_x": "-270", "blue_y": "-125", "type": "1", "value": "window" }, { "id": "17", "yellow_x": "-410", "yellow_y": "-280", "blue_x": "-410", "blue_y": "-125", "type": "4", "value": "5" }, { "id": "18", "yellow_x": "-550", "yellow_y": "-280", "blue_x": "-550", "blue_y": "-125", "type": "1", "value": "door" }, { "id": "19", "yellow_x": "-775", "yellow_y": "-280", "blue_x": "-600", "blue_y": "-125", "type": "1", "value": "blackboard" }, { "id": "20", "yellow_x": "-775", "yellow_y": "-55", "blue_x": "-600", "blue_y": "-55", "type": "1", "value": "window" }, { "id": "21", "yellow_x": "-775", "yellow_y": "80", "blue_x": "-600", "blue_y": "80", "type": "4", "value": "5" }, { "id": "22", "yellow_x": "-775", "yellow_y": "220", "blue_x": "-600", "blue_y": "220", "type": "2", "value": "3" }, { "id": "23", "yellow_x": "-775", "yellow_y": "365", "blue_x": "-600", "blue_y": "365", "type": "1", "value": "door" }, { "id": "24", "yellow_x": "-775", "yellow_y": "550", "blue_x": "-600", "blue_y": "420", "type": "2", "value": "5" }, { "id": "25", "yellow_x": "-550", "yellow_y": "550", "blue_x": "-550", "blue_y": "420", "type": "1", "value": "window" }, { "id": "26", "yellow_x": "-410", "yellow_y": "550", "blue_x": "-410", "blue_y": "420", "type": "4", "value": "5" }, { "id": "27", "yellow_x": "-270", "yellow_y": "550", "blue_x": "-270", "blue_y": "420", "type": "2", "value": "2" }, { "id": "28", "yellow_x": "-130", "yellow_y": "550", "blue_x": "-130", "blue_y": "420", "type": "1", "value": "door" }, { "id": "29", "yellow_x": "10", "yellow_y": "550", "blue_x": "10", "blue_y": "420", "type": "1", "value": "blackboard" }, { "id": "30", "yellow_x": "150", "yellow_y": "550", "blue_x": "150", "blue_y": "420", "type": "3", "value": "1" }, { "id": "31", "yellow_x": "290", "yellow_y": "550", "blue_x": "290", "blue_y": "420", "type": "1", "value": "window" }, { "id": "32", "yellow_x": "430", "yellow_y": "550", "blue_x": "430", "blue_y": "420", "type": "2", "value": "1" }, { "id": "33", "yellow_x": "570", "yellow_y": "550", "blue_x": "570", "blue_y": "420", "type": "4", "value": "5" }, { "id": "34", "yellow_x": "790", "yellow_y": "550", "blue_x": "630", "blue_y": "420", "type": "1", "value": "blackboard" }, { "id": "35", "yellow_x": "790", "yellow_y": "360", "blue_x": "630", "blue_y": "360", "type": "1", "value": "door" }, { "id": "36", "yellow_x": "790", "yellow_y": "215", "blue_x": "630", "blue_y": "215", "type": "2", "value": "3" }, { "id": "37", "yellow_x": "790", "yellow_y": "70", "blue_x": "630", "blue_y": "70", "type": "5", "value": "43" }, { "id": "38", "yellow_x": "790", "yellow_y": "-75", "blue_x": "630", "blue_y": "-75", "type": "3", "value": "1" }, { "id": "39", "yellow_x": "790", "yellow_y": "-220", "blue_x": "630", "blue_y": "-220", "type": "1", "value": "window" }, { "id": "40", "yellow_x": "790", "yellow_y": "-365", "blue_x": "630", "blue_y": "-365", "type": "2", "value": "1" }, { "id": "41", "yellow_x": "790", "yellow_y": "-550", "blue_x": "630", "blue_y": "-405", "type": "1", "value": "blackboard" }, { "id": "42", "yellow_x": "570", "yellow_y": "-550", "blue_x": "570", "blue_y": "-405", "type": "1", "value": "window" }, { "id": "43", "yellow_x": "430", "yellow_y": "-550", "blue_x": "430", "blue_y": "-405", "type": "2", "value": "2" }, { "id": "44", "yellow_x": "290", "yellow_y": "-550", "blue_x": "290", "blue_y": "-405", "type": "1", "value": "door" }, { "id": "45", "yellow_x": "150", "yellow_y": "-550", "blue_x": "150", "blue_y": "-405", "type": "4", "value": "5" }, { "id": "46", "yellow_x": "10", "yellow_y": "-550", "blue_x": "10", "blue_y": "-405", "type": "1", "value": "blackboard" }, { "id": "47", "yellow_x": "-130", "yellow_y": "-550", "blue_x": "-130", "blue_y": "-405", "type": "1", "value": "window" }, { "id": "48", "yellow_x": "-270", "yellow_y": "-550", "blue_x": "-270", "blue_y": "-405", "type": "1", "value": "door" }, { "id": "49", "yellow_x": "-410", "yellow_y": "-550", "blue_x": "-410", "blue_y": "-405", "type": "2", "value": "2" }, { "id": "50", "yellow_x": "-550", "yellow_y": "-550", "blue_x": "-550", "blue_y": "-405", "type": "1", "value": "blackboard" },
{ "id": "51", "yellow_x": "-690", "yellow_y": "-490", "blue_x": "-690", "blue_y": "-490", "type": "100", "value": "0" }]
\ No newline at end of file
{ "id": "51", "yellow_x": "-690", "yellow_y": "-490", "blue_x": "-690", "blue_y": "-490", "type": "100", "value": "0" }
]
\ No newline at end of file
......@@ -14,7 +14,8 @@ class Emitter {
return this;
}
on(event, fn) {
(this._callbacks[event] = this._callbacks[event] || []).push(fn);
if (!this._callbacks[event]) this._callbacks[event] = [];
this._callbacks[event].push(fn);
};
once(event, fn) {
function on() {
......@@ -208,7 +209,7 @@ let pg = {
if (!item) return pg.logger.w("图片更换失败,传入了错误的item");
let node = item.node ? item.node : item;
if (!res) {
node.active = false;
if (node) node.active = false;
return pg.logger.w("图片更换失败,传入了错误的res");
}
if (!node) return pg.logger.w("图片更换失败,传入了错误的item");
......
......@@ -31,7 +31,7 @@ export default class NewClass extends cc.Component {
pg.view.visible(icon_player_dice, true);
for (let i = 1; i <= 6; i++) {
let item = pg.view.find(icon_player_dice, "icon_" + i);
item.active = i == num;
pg.view.visible(item, i == num);
}
} else {
let icon_player = pg.view.find(this.player, "icon_player");
......@@ -48,7 +48,7 @@ export default class NewClass extends cc.Component {
pg.view.visible(icon_robot_dice, true);
for (let i = 1; i <= 6; i++) {
let item = pg.view.find(icon_robot_dice, "icon_" + i);
item.active = i == num;
pg.view.visible(item, i == num);
}
} else {
let icon_robot = pg.view.find(this.robot, "icon_robot");
......
......@@ -33,18 +33,19 @@ export default class NewClass extends cc.Component {
this.bg_goodjob = pg.view.find(this, "bg_goodjob");
this.bg_tryagain = pg.view.find(this, "bg_tryagain");
this.text_tip.active = false;
this.btn_audio_start.active = false;
this.btn_audio_stop.active = false;
this.speak_ske.active = false;
this.bg_goodjob.active = false;
this.bg_tryagain.active = false;
pg.view.visible(this.text_tip, false);
pg.view.visible(this.btn_audio_start, false);
pg.view.visible(this.btn_audio_stop, false);
pg.view.visible(this.speak_ske, false);
pg.view.visible(this.bg_goodjob, false);
pg.view.visible(this.bg_tryagain, false);
pg.view.touchOn(this.btn_audio_start, this.onTouchStart, this);
pg.view.touchOn(this.btn_audio_stop, this.onTouchStop, this);
this.tryCount = 0;
pg.event.on("speak_open", (data) => {
cc.log("speak_open");
this.tryCount = 0;
this.open(data)
})
......@@ -56,33 +57,33 @@ export default class NewClass extends cc.Component {
if (cell) {
this.val = cell.value;
}
this.text_tip.active = true;
this.btn_audio_start.active = true;
this.btn_audio_stop.active = false;
this.speak_ske.active = true;
this.bg_goodjob.active = false;
this.bg_tryagain.active = false;
pg.view.visible(this.text_tip, true);
pg.view.visible(this.btn_audio_start, true);
pg.view.visible(this.btn_audio_stop, false);
pg.view.visible(this.speak_ske, true);
pg.view.visible(this.bg_goodjob, false);
pg.view.visible(this.bg_tryagain, false);
}
close() {
this.text_tip.active = false;
this.btn_audio_start.active = false;
this.btn_audio_stop.active = false;
this.speak_ske.active = false;
this.bg_goodjob.active = false;
this.bg_tryagain.active = false;
pg.view.visible(this.text_tip, false);
pg.view.visible(this.btn_audio_start, false);
pg.view.visible(this.btn_audio_stop, false);
pg.view.visible(this.speak_ske, false);
pg.view.visible(this.bg_goodjob, false);
pg.view.visible(this.bg_tryagain, false);
}
onTouchStart() {
pg.view.playDBAnimation(this.speak_ske, "newAnimation", 0);
this.btn_audio_start.active = false;
this.btn_audio_stop.active = true;
pg.view.visible(this.btn_audio_start, false);
pg.view.visible(this.btn_audio_stop, true);
let win: any = window;
win.courseware && win.courseware.startTest(this.val); //开始录音
}
onTouchStop() {
this.btn_audio_start.active = false;
this.btn_audio_stop.active = false;
pg.view.visible(this.btn_audio_start, false);
pg.view.visible(this.btn_audio_stop, false);
let win: any = window;
if (!win.courseware) {
setTimeout(() => {
......@@ -118,25 +119,25 @@ export default class NewClass extends cc.Component {
}
onRealStop(score) {
pg.view.playDBAnimation(this.speak_ske, "newAnimation", 1);
this.text_tip.active = false;
this.btn_audio_start.active = false;
this.btn_audio_stop.active = false;
this.speak_ske.active = false;
this.bg_goodjob.active = false;
this.bg_tryagain.active = false;
pg.view.visible(this.text_tip, false);
pg.view.visible(this.btn_audio_start, false);
pg.view.visible(this.btn_audio_stop, false);
pg.view.visible(this.speak_ske, false);
pg.view.visible(this.bg_goodjob, false);
pg.view.visible(this.bg_tryagain, false);
setTimeout(() => {
// let score = Math.random() * 100 - 50;
pg.hw.playLocalAudio("goodjob");
if (score > 50) {
this.bg_goodjob.active = true;
pg.view.visible(this.bg_goodjob, true);
setTimeout(() => {
this.close();
pg.event.emit("speak_success");
}, 2000);
} else {
if (this.tryCount >= 1) {
this.bg_tryagain.active = true;
pg.view.visible(this.bg_tryagain, true);
pg.hw.playLocalAudio("tryagain");
this.tryCount++;
//需要处理提供两次机会。重置一次到open状态
......@@ -146,7 +147,7 @@ export default class NewClass extends cc.Component {
}, 2000);
} else {
this.bg_tryagain.active = true;
pg.view.visible(this.bg_tryagain, true);
pg.hw.playLocalAudio("tryagain");
this.tryCount++;
setTimeout(() => {
......
......@@ -30,8 +30,8 @@ export default class NewClass extends cc.Component {
let btn_start = pg.view.find(this, "btn_start");
let btn_restart = pg.view.find(this, "btn_restart");
let bg_vs = pg.view.find(this, "bg_vs");
panel_gray.active = true;
btn_start.active = true;
pg.view.visible(panel_gray, true);
pg.view.visible(btn_start, true);
}
onTouchStart() {
pg.hw.playLocalAudio("vs");
......@@ -39,13 +39,13 @@ export default class NewClass extends cc.Component {
let btn_start = pg.view.find(this, "btn_start");
let btn_restart = pg.view.find(this, "btn_restart");
let bg_vs = pg.view.find(this, "bg_vs");
panel_gray.active = true;
btn_start.active = false;
bg_vs.active = true;
pg.view.visible(panel_gray, true);
pg.view.visible(btn_start, false);
pg.view.visible(bg_vs, true);
pg.event.emit("game_start");
setTimeout(() => {
bg_vs.active = false;
panel_gray.active = false;
pg.view.visible(bg_vs, false);
pg.view.visible(panel_gray, false);
}, 2000);
}
onTouchRestart() {
......@@ -54,14 +54,14 @@ export default class NewClass extends cc.Component {
let btn_start = pg.view.find(this, "btn_start");
let btn_restart = pg.view.find(this, "btn_restart");
let bg_vs = pg.view.find(this, "bg_vs");
panel_gray.active = true;
btn_start.active = false;
btn_restart.active = false;
bg_vs.active = true;
pg.view.visible(panel_gray, true);
pg.view.visible(btn_start, false);
pg.view.visible(btn_restart, false);
pg.view.visible(bg_vs, true);
setTimeout(() => {
bg_vs.active = false;
panel_gray.active = false;
btn_restart.active = false;
pg.view.visible(bg_vs, false);
pg.view.visible(panel_gray, false);
pg.view.visible(btn_restart, false);
pg.event.emit("game_start");
}, 2000);
}
......@@ -69,8 +69,8 @@ export default class NewClass extends cc.Component {
let panel_gray = pg.view.find(this, "panel_gray");
let btn_restart = pg.view.find(this, "btn_restart");
let bg_vs = pg.view.find(this, "bg_vs");
panel_gray.active = true;
btn_restart.active = true;
pg.view.visible(panel_gray, true);
pg.view.visible(btn_restart, true);
}
update(dt) { }
}
......@@ -67,21 +67,22 @@ export default class NewClass extends cc.Component {
if (!number) return;
if (this.num) {
for (let i = 1; i <= 6; i++) {
this[`bg_${i}`].active = false;
pg.view.visible(this[`bg_${i}`], false)
}
for (let i = 1; i <= 6; i++) {
this[`bg_dice${i}`].active = i == number;
pg.view.visible(this[`bg_dice${i}`], i == number)
}
} else {
for (let i = 1; i <= 6; i++) {
this[`bg_${i}`].active = i == number;
pg.view.visible(this[`bg_${i}`], i == number)
}
for (let i = 1; i <= 6; i++) {
this[`bg_dice${i}`].active = false;
pg.view.visible(this[`bg_dice${i}`], false)
}
}
}
update(dt) {
if (!this.node || !this.node.active) return;
if (this.playing) {
let i = Math.floor(Math.random() * 6) + 1;
this.updatePoint(i);
......
......@@ -105,17 +105,17 @@ export class MyCocosSceneComponent extends cc.Component {
});
}
log (str) {
log(str) {
const node = cc.find('middleLayer');
if(node){
if (node) {
node.getComponent('middleLayer').log(str);
}else{
} else {
cc.log(str);
}
}
onLoadEnd() {
}
......@@ -132,7 +132,7 @@ export class MyCocosSceneComponent extends cc.Component {
// ------------------------------------------------
getSprNode(resName) {
const sf = cc.find('Canvas/res/img/' + resName).getComponent(cc.Sprite).spriteFrame;
......@@ -164,7 +164,7 @@ export class MyCocosSceneComponent extends cc.Component {
playAudioByUrl(audio_url, cb = null) {
if (audio_url) {
cc.assetManager.loadRemote(audio_url, (err, audioClip) => {
cc.assetManager.loadRemote(audio_url, (err, audioClip: any) => {
const audioId = cc.audioEngine.play(audioClip, false, 0.8);
if (cb) {
cc.audioEngine.setFinishCallback(audioId, () => {
......
......@@ -102,7 +102,7 @@ export function getDistance (start, end){
export function playAudioByUrl(audio_url, cb=null) {
if (audio_url) {
cc.assetManager.loadRemote(audio_url, (err, audioClip) => {
cc.assetManager.loadRemote(audio_url, (err, audioClip:any) => {
const audioId = cc.audioEngine.play(audioClip, false, 0.8);
if (cb) {
cc.audioEngine.setFinishCallback(audioId, () => {
......
const { spawn } = require("child_process");
const fs = require("fs");
const compressing = require('compressing');
const { v4, parse } = require('uuid');
const { Base64 } = require('js-base64');
const { copyDir, removeDir, fix2 } = require("./utils");
const { spawn } = require("child_process");
const fs = require("fs");
const compressing = require('compressing');
const { v4, parse } = require('uuid');
const { Base64 } = require('js-base64');
const { copyDir, removeDir, fix2 } = require("./utils");
async function buildForm() {
const paths = fs.readdirSync('form');
......@@ -52,7 +52,7 @@ function execCmd(cmd, params, path) {
}
let creatorBasePath = 'C:\\CocosDashboard_1.0.6\\resources\\.editors\\Creator\\2.4.5\\CocosCreator.exe';
let creatorBasePath = 'D:\\work\\CocosDashboard_1.0.9\\resources\\.editors\\Creator\\2.4.5\\CocosCreator.exe';
if (process.platform !== 'win32') {
creatorBasePath = "/Applications/CocosCreator/Creator/2.4.5/CocosCreator.app/Contents/MacOS/CocosCreator";
}
......@@ -128,10 +128,10 @@ async function buildWebBundle() {
await buildCocos(args);
}
function createConfigFile (projectName, type) {
function createConfigFile(projectName, type) {
let iosVersion = "";
let androidVersion = "";
if(!type){
if (!type) {
const androidPaths = fs.readdirSync(`dist/android/${projectName}`);
const androidConfigFileName = androidPaths.find(path => path.indexOf('config') == 0);
androidVersion = androidConfigFileName.split('.')[1];
......@@ -139,17 +139,17 @@ function createConfigFile (projectName, type) {
const iosConfigFileName = iosPaths.find(path => path.indexOf('config') == 0);
iosVersion = iosConfigFileName.split('.')[1];
} else {
if(type=="android"){
if (type == "android") {
const androidPaths = fs.readdirSync(`dist/android/${projectName}`);
const androidConfigFileName = androidPaths.find(path => path.indexOf('config') == 0);
androidVersion = androidConfigFileName.split('.')[1];
}else{
} else {
const iosPaths = fs.readdirSync(`dist/ios/${projectName}`);
const iosConfigFileName = iosPaths.find(path => path.indexOf('config') == 0);
iosVersion = iosConfigFileName.split('.')[1];
}
}
const config = {
"ios": {
"sceneName": projectName,
......@@ -164,7 +164,7 @@ function createConfigFile (projectName, type) {
fs.writeFileSync('dist/config.json', JSON.stringify(config));
}
function compressAll (projectName) {
function compressAll(projectName) {
const tarStream = new compressing.zip.Stream();
tarStream.addEntry('dist/play');
tarStream.addEntry('dist/form');
......@@ -176,7 +176,7 @@ function compressAll (projectName) {
tarStream.pipe(destStream);
}
function build_check () {
function build_check() {
const dirNames = process.cwd().split(/\/|\\/);
const projectName = dirNames[dirNames.length - 1];
const path = 'assets'
......@@ -211,20 +211,20 @@ function build_check () {
return projectName;
}
function changeSettingToWebDesktop () {
function changeSettingToWebDesktop() {
const path = 'assets'
const folderName = getFolderName(path);
editFolderMeta(path, folderName, false);
}
function changeSettingsToBundle () {
function changeSettingsToBundle() {
const path = 'assets'
const folderName = getFolderName(path);
editFolderMeta(path, folderName, true);
}
function replaceUuids () {
function replaceUuids() {
console.log('build_step_0 开始~!');
const path = 'assets'
......@@ -303,7 +303,7 @@ function replaceUuids () {
console.log('build_step_0 完成~!');
}
function replaceIndexHtml () {
function replaceIndexHtml() {
const data = fs.readFileSync('index.html');
fs.writeFileSync('dist/play/index.html', data);
}
......@@ -313,52 +313,52 @@ module.exports = {
build: async function () {
const startTime = new Date().getTime();
// 构建前检查
const projectName = build_check();
// 清理旧文件
// 构建form
await removeDir('dist/form');
await buildForm();
// 替换uuid
replaceUuids();
// 改设置为非bundle
changeSettingToWebDesktop();
// 构建play
await removeDir('dist/play');
await buildWebDesktop();
await copyDir('build/web-desktop', 'dist/play');
replaceIndexHtml();
console.log('构建 web desktop 成功!');
// 改设置为bundle
changeSettingsToBundle();
await removeDir('dist/android');
await buildAndroidBundle();
await copyDir('build_android/jsb-link/remote', 'dist/android');
console.log('构建 android bundle 成功!');
await removeDir('dist/ios');
await buildIosBundle();
await copyDir('build_ios/jsb-link/remote', 'dist/ios');
console.log('构建 ios bundle 成功!');
await removeDir('dist/web_desktop');
await buildWebBundle();
await copyDir(`build_web_desktop/web-desktop/assets/${projectName}`, 'dist/web_desktop');
console.log('构建 web bundle 成功!');
// 改设置为非bundle
changeSettingToWebDesktop();
createConfigFile(projectName);
compressAll(projectName);
await removeDir('build');
......@@ -380,11 +380,11 @@ module.exports = {
replaceUuids();
// 改设置为bundle
changeSettingsToBundle();
await removeDir('dist/android');
await buildAndroidBundle();
await copyDir('build_android/jsb-link/remote', 'dist/android');
// 改设置为非bundle
changeSettingToWebDesktop();
createConfigFile(projectName, "android");
......@@ -400,7 +400,7 @@ module.exports = {
replaceUuids();
// 改设置为bundle
changeSettingsToBundle();
await removeDir('dist/ios');
await buildIosBundle();
await copyDir('build_ios/jsb-link/remote', 'dist/ios');
......
{
"title": "play",
"packageName": "org.cocos2d.demo",
"startScene": "0737ce42-24f0-45c6-8e1a-8bdab4f74ba3",
"startScene": "2d2f792f-a40c-49bb-a189-ed176a246e49",
"excludeScenes": [],
"includeSDKBox": false,
"orientation": {
......@@ -28,7 +28,8 @@
},
"ios": {
"REMOTE_SERVER_ROOT": "",
"packageName": "org.cocos2d.demo"
"packageName": "org.cocos2d.demo",
"ios_enable_jit": true
},
"mac": {
"REMOTE_SERVER_ROOT": "",
......@@ -42,7 +43,7 @@
"width": 1280
},
"android-instant": {
"REMOTE_SERVER_ROOT": "",
"REMOTE_SERVER_ROOT": "http://192.168.43.126:7456/preview-android-instant/",
"host": "",
"packageName": "org.cocos2d.demo",
"pathPattern": "",
......@@ -50,5 +51,7 @@
"scheme": "https",
"skipRecord": false
},
"appBundle": false
"appBundle": false,
"agreements": {},
"includeAnySDK": false
}
{
"last-module-event-record-time": 1600677246969,
"last-module-event-record-time": 1640571810103,
"migrate-history": [
"cloud-function"
]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment