Commit 3772df25 authored by Tt's avatar Tt

修改报错点

parent 7035f505
...@@ -21,8 +21,21 @@ export default class Game { ...@@ -21,8 +21,21 @@ export default class Game {
public robotLevel: number; public robotLevel: number;
constructor() { constructor() {
// //
this.start = false;
} }
public init() {
this.start = false;
this.lists = null;
this.nowStem = null;
this.pause = null;
this.isRobot = null;
this.playerScore = null;
this.robotScore = null;
this.robotLevel = null;
}
public start: boolean;
reset() { reset() {
this.start = true;
this.lists = JSON.parse(JSON.stringify(Data.list)); this.lists = JSON.parse(JSON.stringify(Data.list));
this.pause = false; this.pause = false;
this.isRobot = false; this.isRobot = false;
......
...@@ -39,6 +39,7 @@ export default class NewClass extends MyCocosSceneComponent { ...@@ -39,6 +39,7 @@ export default class NewClass extends MyCocosSceneComponent {
cc.Tween.stopAll(); cc.Tween.stopAll();
this.unscheduleAllCallbacks(); this.unscheduleAllCallbacks();
pg.event.off("game_start") pg.event.off("game_start")
pg.event.off("item_touch_right")
pg.event.off("speak_success"); pg.event.off("speak_success");
pg.event.off("speak_fail"); pg.event.off("speak_fail");
} }
...@@ -49,7 +50,7 @@ export default class NewClass extends MyCocosSceneComponent { ...@@ -49,7 +50,7 @@ export default class NewClass extends MyCocosSceneComponent {
this.log("test initData") this.log("test initData")
// 所有全局变量 默认都是null // 所有全局变量 默认都是null
this._cantouch = true; this._cantouch = true;
Game.getIns().reset(); Game.getIns().init();
//开始显示企鹅 //开始显示企鹅
} }
initView() { initView() {
......
// Learn TypeScript:
// - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
const { ccclass, property } = cc._decorator;
@ccclass
export default class NewClass extends cc.Component {
@property(cc.Label)
label: cc.Label = null;
@property
text: string = 'hello';
// LIFE-CYCLE CALLBACKS:
private count = 0;
onLoad() {
this.count = 0;
}
update(dt) {
this.count++;
this.updateItems();
}
updateItems() {
}
}
{
"ver": "1.0.8",
"uuid": "764039ec-62e7-416b-a01b-1f8dd451a870",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
// Learn TypeScript:
// - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
import movement from "./movements";
const { ccclass, property } = cc._decorator;
interface Point {
id: string;
blue_x: string;
blue_y: string;
yellow_x: string;
yellow_y: string;
}
@ccclass
export default class NewClass extends cc.Component {
@property
isRobot: boolean = false;
// LIFE-CYCLE CALLBACKS:
onLoad() {
}
protected onDestroy(): void {
cc.Tween.stopAll();
this.unscheduleAllCallbacks();
}
private lastPoints: Array<Point>;
run(points: Array<Point>) {
return new Promise((resolve, reject) => {
this.lastPoints = points;
let posArray = this.getPos(points);
let point0 = posArray.shift();
this.node.x = point0.x;
this.node.y = point0.y;
let movementList = []
for (let i = 0; i < posArray.length; i++) {
let pos = posArray[i];
movementList.push({
id: i,
time: 0.4,
x: pos.x,
y: pos.y,
audionode: "star"
})
}
movement.loadTween(this.node, movementList).then(() => {
resolve('');
})
});
}
getPos(points: Array<Point>) {
let posArray = points.map(li => {
let pos: any = {
x: this.isRobot ? li.blue_x : li.yellow_x,
y: this.isRobot ? li.blue_y : li.yellow_y
}
pos.x = Number(pos.x);
pos.y = Number(pos.y);
return pos;
});
return posArray;
}
// update (dt) {}
}
{
"ver": "1.0.8",
"uuid": "00040df5-e4c9-4c8d-9fea-65b709873399",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
...@@ -19,11 +19,11 @@ export default class NewClass extends cc.Component { ...@@ -19,11 +19,11 @@ export default class NewClass extends cc.Component {
this.player = pg.view.find(this, "player"); this.player = pg.view.find(this, "player");
this.robot = pg.view.find(this, "robot"); this.robot = pg.view.find(this, "robot");
pg.event.on("player_point_update", (data) => { // pg.event.on("player_point_update", (data) => {
}) // })
} }
protected onDestroy(): void { protected onDestroy(): void {
pg.event.off("player_point_update"); // pg.event.off("player_point_update");
} }
updatePlayer() { updatePlayer() {
let icon_player = pg.view.find(this.player, "icon_player"); let icon_player = pg.view.find(this.player, "icon_player");
...@@ -42,6 +42,7 @@ export default class NewClass extends cc.Component { ...@@ -42,6 +42,7 @@ export default class NewClass extends cc.Component {
pg.view.setString(score, `${Game.getIns().playerScore} : ${Game.getIns().robotScore}`); pg.view.setString(score, `${Game.getIns().playerScore} : ${Game.getIns().robotScore}`);
} }
update(dt) { update(dt) {
if (!Game || !Game.getIns() || !Game.getIns().start) return;
this.updatePlayer(); this.updatePlayer();
this.updateRobot(); this.updateRobot();
this.updateScore(); this.updateScore();
......
// Learn TypeScript:
// - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
import pg from "./pg";
const { ccclass, property } = cc._decorator;
@ccclass
export default class NewClass extends cc.Component {
@property(cc.Label)
label: cc.Label = null;
@property
text: string = 'hello';
// LIFE-CYCLE CALLBACKS:
private bg_1: cc.Node;
private bg_2: cc.Node;
private bg_3: cc.Node;
private bg_4: cc.Node;
private bg_5: cc.Node;
private bg_6: cc.Node;
private bg_dice1: cc.Node;
private bg_dice2: cc.Node;
private bg_dice3: cc.Node;
private bg_dice4: cc.Node;
private bg_dice5: cc.Node;
private bg_dice6: cc.Node;
onLoad() {
this.bg_1 = pg.view.find(this, "bg_1");
this.bg_2 = pg.view.find(this, "bg_2");
this.bg_3 = pg.view.find(this, "bg_3");
this.bg_4 = pg.view.find(this, "bg_4");
this.bg_5 = pg.view.find(this, "bg_5");
this.bg_6 = pg.view.find(this, "bg_6");
this.bg_dice1 = pg.view.find(this, "bg_dice1");
this.bg_dice2 = pg.view.find(this, "bg_dice2");
this.bg_dice3 = pg.view.find(this, "bg_dice3");
this.bg_dice4 = pg.view.find(this, "bg_dice4");
this.bg_dice5 = pg.view.find(this, "bg_dice5");
this.bg_dice6 = pg.view.find(this, "bg_dice6");
}
protected onDestroy(): void {
cc.Tween.stopAll();
this.unscheduleAllCallbacks();
}
private playing: boolean;
private num: number;
startAni() {
this.playing = true;
this.num = null;
}
stopAni(number) {
return new Promise((resolve, reject) => {
this.num = number;
this.playing = false;
this.scheduleOnce(() => {
resolve('');
}, 1.5)
});
}
start() {
}
updatePoint(number) {
if (!number) return;
if (this.num) {
for (let i = 1; i <= 6; i++) {
pg.view.visible(this[`bg_${i}`], false)
}
for (let i = 1; i <= 6; i++) {
pg.view.visible(this[`bg_dice${i}`], i == number)
}
} else {
for (let i = 1; i <= 6; i++) {
pg.view.visible(this[`bg_${i}`], i == number)
}
for (let i = 1; i <= 6; i++) {
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);
} else {
this.updatePoint(this.num);
}
}
}
{
"ver": "1.0.8",
"uuid": "96a89d6c-d01a-480c-8b3b-38cf93279c5c",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
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