Commit b783042c authored by yu's avatar yu

点击适配,重复点击

parent 3209a81b
...@@ -41,8 +41,11 @@ cc.Class({ ...@@ -41,8 +41,11 @@ cc.Class({
let db = this.ske.getComponent(dragonBones.ArmatureDisplay) let db = this.ske.getComponent(dragonBones.ArmatureDisplay)
db.playAnimation('normal', 1); db.playAnimation('normal', 1);
db.addEventListener("loopComplete", () => { db.addEventListener("loopComplete", () => {
resolve(''); // resolve('');
}) })
setTimeout(() => {
resolve('');
}, 2000);
}); });
} }
// update (dt) {}, // update (dt) {},
......
...@@ -195,30 +195,40 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -195,30 +195,40 @@ export default class SceneComponent extends MyCocosSceneComponent {
item.data = data item.data = data
item.active = true; item.active = true;
} }
private setTouchPos(e) {
let location = e.getLocation();
let size = cc.view.getCanvasSize();
let scale = (size.width / size.height) / (1280 / 720);
if (scale > 1) {
let width = size.width / size.height * 720;
let pos = location.sub(cc.v2(width / 2, 720 / 2))
e.target.setPosition(pos)
} else {
let height = size.height / size.width * 1280;
let pos = location.sub(cc.v2(1280 / 2, height / 2))
e.target.setPosition(pos)
}
}
onItemTouchStart(e) { onItemTouchStart(e) {
let target: cc.Node = e.target; let target: cc.Node = e.target;
let data = target.data; let data = target.data;
let location = e.getLocation(); if (data.isChecked) return;
let size = cc.view.getCanvasSize(); this.setTouchPos(e);
let height = size.height / size.width * 1280;
let pos = location.sub(cc.v2(1280 / 2, height / 2))
e.target.setPosition(pos)
} }
onItemTouchMove(e) { onItemTouchMove(e) {
let target: cc.Node = e.target; let target: cc.Node = e.target;
let location = e.getLocation(); let data = target.data;
let size = cc.view.getCanvasSize(); if (data.isChecked) return;
let height = size.height / size.width * 1280; this.setTouchPos(e);
let pos = location.sub(cc.v2(1280 / 2, height / 2))
e.target.setPosition(pos)
} }
onItemTouchEnd(e) { onItemTouchEnd(e) {
// //
let target: cc.Node = e.target; let target: cc.Node = e.target;
let data = target.data; let data = target.data;
if (data.isChecked) return;
let rect1 = cc.rect(target.x, target.y, target.width * target.scale, target.height * target.scale); let rect1 = cc.rect(target.x, target.y, target.width * target.scale, target.height * target.scale);
let itemBg = this.cardBgs.find(bg => { let itemBg = this.cardBgs.find(bg => {
return rect1.intersects(cc.rect(bg.x, bg.y, bg.width * bg.scale, bg.height * bg.scale)); return rect1.intersects(cc.rect(bg.x, bg.y, bg.width * bg.scale, bg.height * bg.scale / 2));
}) })
if (!itemBg || this.currentCards[itemBg.data.count]) { if (!itemBg || this.currentCards[itemBg.data.count]) {
//回退 //回退
...@@ -237,6 +247,7 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -237,6 +247,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
let pos = this.getBgPostionById(itemBg.data.count); let pos = this.getBgPostionById(itemBg.data.count);
target.setPosition(pos); target.setPosition(pos);
this.currentCards[itemBg.data.count] = target; this.currentCards[itemBg.data.count] = target;
data.isChecked = true;
this.playLocalAudio("right"); this.playLocalAudio("right");
let ani_flower = cc.instantiate(this.ani_flower); let ani_flower = cc.instantiate(this.ani_flower);
...@@ -274,6 +285,7 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -274,6 +285,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.playLocalAudio("error"); this.playLocalAudio("error");
this.currentCards.forEach(card => { this.currentCards.forEach(card => {
cc.tween(card).to(0.3, { x: this.getPostionById(card.data.count).x, y: this.getPostionById(card.data.count).y }).start(); cc.tween(card).to(0.3, { x: this.getPostionById(card.data.count).x, y: this.getPostionById(card.data.count).y }).start();
card.data.isChecked = false;
}) })
this.currentCards.length = 0; this.currentCards.length = 0;
return; return;
......
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