Commit c869828c authored by yu's avatar yu

1

parent 2f32178a
......@@ -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_MOVE, this.onItemTouchMove, 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_MOVE, this.onItemTouchMove, 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;
......@@ -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) {
if (this.isFinish) return;
this.isTouch = true;
this.playLocalAudio("click");
// if (this.checkRoundOver()) return;
let target: cc.Node = e.target;
......@@ -228,6 +241,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
onItemTouchMove(e) {
if (this.isFinish) return;
this.isTouch = true;
// if (this.checkRoundOver()) return;
let target: cc.Node = e.target;
let data = target.data;
......@@ -236,6 +250,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
onItemTouchEnd(e) {
if (this.isFinish) return;
this.isTouch = false;
cc.audioEngine.stopAllEffects()
// if (this.checkRoundOver()) return;
let target: cc.Node = e.target;
......@@ -257,12 +272,14 @@ export default class SceneComponent extends MyCocosSceneComponent {
return;
}
if (itemBg.data.page != data.page) {
this.errorMove = true;
this.playLocalAudio("error");
let img_pro = cc.find("img_pro", target);
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(() => {
target.parent = this.layout_card;
img_pro.active = false;
this.errorMove = false;
}).start();
return;
}
......@@ -289,6 +306,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
target.destroy();
bg_bar_font.active = true;
bg_bar_img.active = false;
if (!this.errorMove && !this.isTouch)
if (this.layout_card.children.length <= 0) {
this.rundEnd();
}
......@@ -304,7 +322,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
// this.playLocalAudio("right");
// pg.event.emit("mouse_08_add");
}
private errorMove = false;
private setTouchPos(e) {
let location = e.getLocation();
let size = cc.view.getCanvasSize();
......@@ -419,6 +437,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
})
}
private rundEnd() {
if (Game.getIns().state == GAME_STATE.OVER) return;
Game.getIns().state = GAME_STATE.OVER;
// this.sendData(this.data.questions.length * 3).then(() => {
// 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