Commit 83c91eb1 authored by Tt's avatar Tt

bug

parent b5e79f78
......@@ -2,6 +2,8 @@
// letter: 'test',
// targetTime: 10
// })
//pg.event.on('layer_record_start_record',()=>{});
//pg.event.on('layer_record_end_record',()=>{});
import pg from "../../scene/pg_hy01_danci";
......
......@@ -71,24 +71,26 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.layer_word_little = pg.view.find(this, 'layer_word_little')
this.layer_touch = pg.view.find(this, 'layer_touch')
pg.view.touchStartOn(this.layer_touch, this.onTouchPanelGameDown, this);
pg.view.touchEndOn(this.layer_touch, this.onTouchPanelGameUp, this);
pg.view.touchMoveOn(this.layer_touch, this.onTouchPanelMove, this);
pg.view.touchCancelOn(this.layer_touch, this.onTouchPanelGameUp, this);
}
// 播放中不让点
// 录音中不让点
private touchForbid: boolean;
onTouchPanelMove(e: cc.Event.EventTouch) {
if (this.touchForbid) return;
//加一些限制
let touchPoint = e.getLocation();
let startPoint = e.getStartLocation();
let move = touchPoint.clone().subtract(startPoint);
console.log(move.toString());
if (Math.abs(move.x) > 50) {
if (move.x < 0) {
if (move.x < -10) {
this.touchForbid = true;
this.lastPage();
} else if (move.x > 0) {
} else if (move.x > 10) {
this.touchForbid = true;
this.nextPage();
}
}
}
lastPage() {
this.lastLayer();
}
......@@ -102,8 +104,17 @@ export default class SceneComponent extends MyCocosSceneComponent {
pg.event.on('layer_record_score', (score) => {
this.onRecorScore(score);
})
pg.event.on('layer_record_start_record', () => {
this.touchForbid = true;
});
pg.event.on('layer_record_end_record', () => {
this.touchForbid = false;
});
}
private get LastData() {
return this.list[this.count - 1]
}
private get CurrentData() {
return this.list[this.count]
}
......@@ -113,14 +124,17 @@ export default class SceneComponent extends MyCocosSceneComponent {
private get OutData() {
return this.list[this.count + 2]
}
private get LastLayer() {
return this.layers[this.count - 1]
}
private get CurrentLayer() {
return this.layers[0]
return this.layers[this.count]
}
private get LittleLayer() {
return this.layers[1]
return this.layers[this.count + 1]
}
private get OutLayer() {
return this.layers[2]
return this.layers[this.count + 2]
}
private count: number;
......@@ -134,10 +148,12 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.layers.push(nextLayer)
}
startGame() {
this.touchForbid = false;
this.startPlay();
}
startPlay() {
if (this.recordFlag) {
this.touchForbid = false;
pg.event.emit('layer_record_open', {
letter: this.CurrentData.content,
targetTime: this.CurrentData.duration
......@@ -214,17 +230,26 @@ export default class SceneComponent extends MyCocosSceneComponent {
lastLayer() {
alert("上一题")
// 积分需要计算,未获取的内容
this.count--;
if (!this.LastData) return;
cc.tween(this.lastLayer).to(3, { x: 0, y: 0, scale: 1 }).start();
cc.tween(this.CurrentLayer).to(3, { x: this.layer_word_little.x, y: this.layer_word_little.y, scale: this.layer_word_little.scale }).start();
if (this.nextLayer) {
cc.tween(this.nextLayer).to(3, { x: -1500 }).start();
}
this.scheduleOnce(() => {
this.count--;
this.startPlay();
}, 3)
}
nextLayer() {
this.touchForbid = true;
if (!this.NextData) {
this.gameOver();
return;
}
if (this.OutData) {
if (this.OutData && !this.OutLayer) {
let outLayer = this.createLittleLayer();
this.updateLayer(outLayer, this.OutData)
outLayer.x = -1500;
......@@ -240,7 +265,6 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
this.scheduleOnce(() => {
this.count++;
this.layers.shift();
this.startPlay();
}, 3)
}
......
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