Commit 1cdcf8a7 authored by linzhiguo's avatar linzhiguo

# 命中组优化

parent 6e8cea61
...@@ -293,7 +293,10 @@ cc.Class({ ...@@ -293,7 +293,10 @@ cc.Class({
return; return;
//this._moved = true; //this._moved = true;
this._touched = false; this._touched = false;
selected.target.active = true; if (selected.target){
selected.target.active = true;
selected.target = null;
}
selected.node.x = selected.cx; selected.node.x = selected.cx;
selected.node.y = selected.cy; selected.node.y = selected.cy;
}, this); }, this);
...@@ -304,23 +307,26 @@ cc.Class({ ...@@ -304,23 +307,26 @@ cc.Class({
return; return;
let item, area, len = this._kind_group.node.childrenCount; let item, area, len = this._kind_group.node.childrenCount;
let i = 0; let dis = 99999999, idx = -1;
for(i = 0; i < len; i++){ for(let i = 0; i < len; i++){
item = this._kind_group.node.children[i]; item = this._kind_group.node.children[i];
area = item.getChildByName('layout_area'); area = item.getChildByName('layout_area');
let rect = area.getBoundingBoxToWorld(); let rect = area.getBoundingBoxToWorld();
rect.width -= 20; rect.width -= 20;
rect.x += 10; rect.x += 10;
if (cc.rect(rect).intersects(cc.rect(selected.node.getBoundingBoxToWorld()))){ if (cc.rect(rect).intersects(cc.rect(selected.node.getBoundingBoxToWorld()))){
// console.log(i); let _dis = cc.Vec2.squaredDistance(item.convertToWorldSpaceAR(cc.v2(0,0)), selected.node.convertToWorldSpaceAR(cc.v2(0,0)));
// console.log(item.getBoundingBoxToWorld()); if (dis > _dis){
let kind = item.getComponent(cc.js.getClassByName('WordKind')); dis = _dis;
if (kind.kind_id != selected.kind_id){ idx = i;
//this.playAudioByName('incorrect');
//break;
continue;
} }
}
}
if (idx >= 0){
item = this._kind_group.node.children[idx];
let kind = item.getComponent(cc.js.getClassByName('WordKind'));
if (kind.kind_id == selected.kind_id){
this.playAudioByName('correct'); this.playAudioByName('correct');
let node = cc.instantiate(cc.find('res/option_item')); let node = cc.instantiate(cc.find('res/option_item'));
let ot = node.getComponent(cc.js.getClassByName('WordOption')); let ot = node.getComponent(cc.js.getClassByName('WordOption'));
...@@ -332,25 +338,15 @@ cc.Class({ ...@@ -332,25 +338,15 @@ cc.Class({
if (this.tryFinish()) if (this.tryFinish())
this.pageFinish(); this.pageFinish();
}); });
// cc.tween(this) ot.playAudio();
// .delay(0.2)
// .call(()=>{
ot.playAudio();
// })
// .start();
//this._xs[i%2] += selected.target._w;
selected.target.active = false; selected.target.active = false;
//selected.target.removeFromParent();
selected.target = null; selected.target = null;
break;
} }
} }
if (i == len){ else{
this.playAudioByName('incorrect'); this.playAudioByName('incorrect');
} }
this._moved = true; this._moved = true;
this._touched = false; this._touched = false;
if (selected.target){ if (selected.target){
......
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