Commit c5b1bac9 authored by yu's avatar yu

10.12调整

parent 3c4bf285
{
"ver": "2.0.1",
"uuid": "a8f3aec7-9102-4431-acd8-31cd12bccd96",
"downloadMode": 0,
"duration": 3.787755,
"subMetas": {}
}
\ No newline at end of file
This diff is collapsed.
......@@ -86,6 +86,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
private tryData: Array<Option>;
private timeSecond;
private assessCount;
private isClick = true;
initData() {
Game.getIns().init(this.data);
Game.getIns().reset();
......@@ -94,6 +95,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.startSecond = false;
this.timeSecond = 0;
this.assessCount = 0;
this.isClick = true;
}
private layout_start: cc.Node;
private audioId: any;
......@@ -198,16 +200,33 @@ export default class SceneComponent extends MyCocosSceneComponent {
let c_d = data.wordArr[idx];
if (!c_d) ch.active = false;
this.initCloudItem(ch, c_d);
this.floatAction(ch);
let iData: any = {};
iData.x = ch.x;
iData.y = ch.y;
ch.data = iData;
this.floatForeverAction(ch);
});
layout_bridge.children.forEach((item, idx) => {
let c_d = data.wordArr[idx];
if (!c_d) item.active = false;
let iData: any = {};
iData.x = item.x;
iData.y = item.y;
item.data = iData;
let word = cc.find("word", item);
word.getComponent(cc.Label).string = "";
word.getComponent(cc.Label).string = c_d;
word.active = false;
this.wordItams.push(item);
let bData: any = {};
bData.text = c_d;
bData.parent = word.parent;
bData.startPos = word.getPosition();
word.data = bData;
word.on(cc.Node.EventType.TOUCH_START, this.onBridgeStart, this);
word.on(cc.Node.EventType.TOUCH_MOVE, this.onBridgeMove, this);
word.on(cc.Node.EventType.TOUCH_END, this.onBridgeEnd, this);
});
this.isClick = true;
}
private initCloudItem(item, text) {
let word = cc.find("word", item);
......@@ -264,6 +283,8 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
onItemTouchStart(e) {
if (!this.isClick) return;
if (e.target.getComponent(cc.Label).string == "") return;
this.playLocalAudio("takeout");
// if (this.checkRoundOver()) return;
let target: cc.Node = e.target;
......@@ -276,6 +297,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.setTouchPos(e);
}
onItemTouchMove(e) {
if (!this.isClick) return;
// if (this.checkRoundOver()) return;
let target: cc.Node = e.target;
let data = target.data;
......@@ -283,6 +305,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.setTouchPos(e);
}
onItemTouchEnd(e) {
if (!this.isClick) return;
// if (this.checkRoundOver()) return;
let target: cc.Node = e.target;
let data = target.data;
......@@ -290,7 +313,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
// let dis = this.getDistances(target.getPosition(), bg.getPosition());
let dis = this.getDistances(target, bg);
// if (dis < 100 && bg.sortId == data.id) {
if (dis < bg.width / 2 && !cc.find("word", bg).active) {
if (dis < bg.width / 2 && !cc.find("word", bg).active && bg.active) {
return bg;
}
return null;
......@@ -299,12 +322,17 @@ export default class SceneComponent extends MyCocosSceneComponent {
target.setPosition(data.startPos);
target.active = false;
if (!itemBg) return target.active = true;
if (!itemBg) {
target.active = true;
this.floatForeverAction(target.parent);
return
}
this.floatAction(itemBg);
let word = cc.find("word", itemBg);
word.active = true;
word.getComponent(cc.Label).string = data.text;
// word.getComponent(cc.Label).string = data.text;
word.data.CParent = data.parent;
this.playLocalAudio("move")
if (this.checkRoundOver()) {
......@@ -328,6 +356,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
} else {
Game.getIns().failCount++;
this.isClick = false;
this.playLocalAudio("error").then(() => {
this.showQuestion();
});
......@@ -336,6 +365,46 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
private onBridgeStart(e) {
if (!this.isClick) return;
let target: cc.Node = e.target;
this.floatAction(target.parent);
target.parent = this.node;
this.setTouchPos(e);
}
private onBridgeMove(e) {
if (!this.isClick) return;
let target: cc.Node = e.target;
this.setTouchPos(e);
}
private onBridgeEnd(e) {
if (!this.isClick) return;
let target: cc.Node = e.target;
let data = target.data;
let itemBg = this.wordItams.find((bg) => {
// let dis = this.getDistances(target.getPosition(), bg.getPosition());
let dis = this.getDistances(target, bg);
// if (dis < 100 && bg.sortId == data.id) {
if (dis > bg.width) {
return bg;
}
return null;
})
target.parent = data.parent;
target.setPosition(data.startPos);
if (!itemBg) return;
target.active = false;
let cloud = data.CParent;
if (cloud) {
this.floatForeverAction(cloud);
let word = cc.find("word", cloud);
if (word) {
word.active = true;
// word.getComponent(cc.Label).string = data.text;
}
}
}
private checkRoundOver() {
let count = 0;
......@@ -360,9 +429,23 @@ export default class SceneComponent extends MyCocosSceneComponent {
private floatAction(target) {
cc.Tween.stopAllByTarget(target);
cc.tween(target).by(0.15, { y: -20 }).by(0.3, { y: 20 }).start();
let data = target.data;
target.x = data.x;
target.y = data.y;
let y1 = target.y - 20;
let y2 = target.y;
cc.tween(target).to(0.15, { y: y1 }).to(0.3, { y: y2 }).start();
}
private floatForeverAction(target) {
cc.Tween.stopAllByTarget(target);
let data = target.data;
target.x = data.x;
target.y = data.y;
let y1 = target.y - 10;
let y2 = target.y;
cc.tween(target).repeatForever(cc.tween().to(0.5 + Math.random() * 1.5, { y: y1 }).to(0.5 + Math.random() * 1.5, { y: y2 })).start();
}
......@@ -480,7 +563,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
})
}
private showFind() {
// this.playLocalAudio("complete");
this.playLocalAudio("wancheng");
this.startSecond = false;
this.layout_final.scale = 0.3;
this.layout_final.active = true;
......
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