Commit 83c91eb1 authored by Tt's avatar Tt

bug

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