Commit c869828c authored by yu's avatar yu

1

parent 2f32178a
...@@ -197,10 +197,12 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -197,10 +197,12 @@ export default class SceneComponent extends MyCocosSceneComponent {
card.off(cc.Node.EventType.TOUCH_START, this.onItemTouchStart, this); card.off(cc.Node.EventType.TOUCH_START, this.onItemTouchStart, this);
card.off(cc.Node.EventType.TOUCH_MOVE, this.onItemTouchMove, this); card.off(cc.Node.EventType.TOUCH_MOVE, this.onItemTouchMove, this);
card.off(cc.Node.EventType.TOUCH_END, this.onItemTouchEnd, this); card.off(cc.Node.EventType.TOUCH_END, this.onItemTouchEnd, this);
card.off(cc.Node.EventType.TOUCH_CANCEL, this.onItemTouchCancel, this);
card.on(cc.Node.EventType.TOUCH_START, this.onItemTouchStart, this); card.on(cc.Node.EventType.TOUCH_START, this.onItemTouchStart, this);
card.on(cc.Node.EventType.TOUCH_MOVE, this.onItemTouchMove, this); card.on(cc.Node.EventType.TOUCH_MOVE, this.onItemTouchMove, this);
card.on(cc.Node.EventType.TOUCH_END, this.onItemTouchEnd, this); card.on(cc.Node.EventType.TOUCH_END, this.onItemTouchEnd, this);
card.on(cc.Node.EventType.TOUCH_CANCEL, this.onItemTouchCancel, this);
}) })
this.layout_box.getComponent(cc.Layout).spacingX = ques.length >= 4 ? 90 : 200; this.layout_box.getComponent(cc.Layout).spacingX = ques.length >= 4 ? 90 : 200;
...@@ -213,9 +215,20 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -213,9 +215,20 @@ export default class SceneComponent extends MyCocosSceneComponent {
}) })
} }
onItemTouchCancel(e) {
this.isTouch = false;
let target: cc.Node = e.target;
let data = target.data;
this.errorMove = true;
this.playLocalAudio("error");
target.parent = this.layout_card;
target.x = data.x;
target.y = data.y;
}
private isTouch = false;
onItemTouchStart(e) { onItemTouchStart(e) {
if (this.isFinish) return; if (this.isFinish) return;
this.isTouch = true;
this.playLocalAudio("click"); this.playLocalAudio("click");
// if (this.checkRoundOver()) return; // if (this.checkRoundOver()) return;
let target: cc.Node = e.target; let target: cc.Node = e.target;
...@@ -228,6 +241,7 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -228,6 +241,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
} }
onItemTouchMove(e) { onItemTouchMove(e) {
if (this.isFinish) return; if (this.isFinish) return;
this.isTouch = true;
// if (this.checkRoundOver()) return; // if (this.checkRoundOver()) return;
let target: cc.Node = e.target; let target: cc.Node = e.target;
let data = target.data; let data = target.data;
...@@ -236,6 +250,7 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -236,6 +250,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
} }
onItemTouchEnd(e) { onItemTouchEnd(e) {
if (this.isFinish) return; if (this.isFinish) return;
this.isTouch = false;
cc.audioEngine.stopAllEffects() cc.audioEngine.stopAllEffects()
// if (this.checkRoundOver()) return; // if (this.checkRoundOver()) return;
let target: cc.Node = e.target; let target: cc.Node = e.target;
...@@ -257,12 +272,14 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -257,12 +272,14 @@ export default class SceneComponent extends MyCocosSceneComponent {
return; return;
} }
if (itemBg.data.page != data.page) { if (itemBg.data.page != data.page) {
this.errorMove = true;
this.playLocalAudio("error"); this.playLocalAudio("error");
let img_pro = cc.find("img_pro", target); let img_pro = cc.find("img_pro", target);
img_pro.active = true; img_pro.active = true;
cc.tween(target).to(0.2, { angle: 15 }).to(0.2, { angle: -15 }).to(0.2, { angle: 15 }).to(0.2, { angle: -15 }).to(0.2, { angle: 0 }).to(0.2, { x: data.x, y: data.y }).call(() => { cc.tween(target).to(0.2, { angle: 15 }).to(0.2, { angle: -15 }).to(0.2, { angle: 15 }).to(0.2, { angle: -15 }).to(0.2, { angle: 0 }).to(0.2, { x: data.x, y: data.y }).call(() => {
target.parent = this.layout_card; target.parent = this.layout_card;
img_pro.active = false; img_pro.active = false;
this.errorMove = false;
}).start(); }).start();
return; return;
} }
...@@ -289,9 +306,10 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -289,9 +306,10 @@ export default class SceneComponent extends MyCocosSceneComponent {
target.destroy(); target.destroy();
bg_bar_font.active = true; bg_bar_font.active = true;
bg_bar_img.active = false; bg_bar_img.active = false;
if (this.layout_card.children.length <= 0) { if (!this.errorMove && !this.isTouch)
this.rundEnd(); if (this.layout_card.children.length <= 0) {
} this.rundEnd();
}
}).start(); }).start();
...@@ -304,7 +322,7 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -304,7 +322,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
// this.playLocalAudio("right"); // this.playLocalAudio("right");
// pg.event.emit("mouse_08_add"); // pg.event.emit("mouse_08_add");
} }
private errorMove = false;
private setTouchPos(e) { private setTouchPos(e) {
let location = e.getLocation(); let location = e.getLocation();
let size = cc.view.getCanvasSize(); let size = cc.view.getCanvasSize();
...@@ -419,6 +437,7 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -419,6 +437,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
}) })
} }
private rundEnd() { private rundEnd() {
if (Game.getIns().state == GAME_STATE.OVER) return;
Game.getIns().state = GAME_STATE.OVER; Game.getIns().state = GAME_STATE.OVER;
// this.sendData(this.data.questions.length * 3).then(() => { // this.sendData(this.data.questions.length * 3).then(() => {
// let mid = cc.find('middleLayer'); // let mid = cc.find('middleLayer');
......
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