Commit a4336c82 authored by Tt's avatar Tt

正确动效

parent b1c207ea
...@@ -375,9 +375,11 @@ cc.Class({ ...@@ -375,9 +375,11 @@ cc.Class({
break; break;
} }
}, },
moveItem(item, pos) { backItem(item, pos) {
item.x = pos.x; item.x = pos.x;
item.y = pos.y; item.y = pos.y;
item.moveState = 0;
this.updateItem(item);
}, },
initButton(item) { initButton(item) {
item.on(cc.Node.EventType.TOUCH_START, this.onStartItem, this); item.on(cc.Node.EventType.TOUCH_START, this.onStartItem, this);
...@@ -390,11 +392,6 @@ cc.Class({ ...@@ -390,11 +392,6 @@ cc.Class({
if (item.moveState == 2) return; if (item.moveState == 2) return;
//判断是否是在原地并没有到处移动 //判断是否是在原地并没有到处移动
this._startPos = cc.v2(touch.target.x, touch.target.y); this._startPos = cc.v2(touch.target.x, touch.target.y);
//有点击行为不进行位移
// let touchPos = touch.getLocation();
// touch.target.x = touchPos.x - 1280 / 2;
// touch.target.y = touchPos.y - 720 / 2;
}, },
//1.移动效果--在节点上绑定一个运动的type 根据type来刷新按钮效果 刷新type的方法,和具体的执行的时候刷新type //1.移动效果--在节点上绑定一个运动的type 根据type来刷新按钮效果 刷新type的方法,和具体的执行的时候刷新type
//2.成功效果-- //2.成功效果--
...@@ -414,7 +411,7 @@ cc.Class({ ...@@ -414,7 +411,7 @@ cc.Class({
height: 50,//item.height height: 50,//item.height
})) { })) {
//回归原位 //回归原位
this.moveItem(item, this._startPos); this.backItem(item, this._startPos);
//变换动画 //变换动画
ani.flipX0(item).then(() => { ani.flipX0(item).then(() => {
item.cardState = item.cardState == 0 ? 1 : 0; item.cardState = item.cardState == 0 ? 1 : 0;
...@@ -429,21 +426,24 @@ cc.Class({ ...@@ -429,21 +426,24 @@ cc.Class({
//成功 失败的判断 根据id //成功 失败的判断 根据id
let successed = box.data.child.some(dt => dt.cardId == item.data.cardId); let successed = box.data.child.some(dt => dt.cardId == item.data.cardId);
if (successed) { if (successed) {
item.moveState = 2; this.createRightAni(cc.v2(item.x, item.y));
this.updateItem(item); setTimeout(() => {
box.data.success.push(item); //检测是否全部完成
this.setSuccessItemPos(box, item); item.moveState = 2;
//检测是否全部完成 this.updateItem(item);
box.data.success.push(item);
this.setSuccessItemPos(box, item);
}, 300);
} else { } else {
item.moveState = 3; item.moveState = 3;
this.updateItem(item); this.updateItem(item);
// //碰撞失败退回原位置 //碰撞失败退回原位置
setTimeout(() => { setTimeout(() => {
this.moveItem(item, this._startPos); this.backItem(item, this._startPos);
}, 100); }, 300);
} }
} else { } else {
this.moveItem(item, this._startPos); this.backItem(item, this._startPos);
} }
}, },
onMoveItem(touch) { onMoveItem(touch) {
......
{"name":"right","imagePath":"right_tex.png","SubTexture":[{"name":"1/圆","x":1,"height":98,"y":1,"width":98},{"name":"1/星1","x":66,"height":59,"y":172,"width":57},{"name":"1/星2","x":71,"height":45,"y":101,"width":43},{"name":"1/星3","x":1,"height":64,"y":172,"width":63},{"name":"1/星4","x":183,"height":45,"y":172,"width":45},{"name":"1/星6","x":1,"height":69,"y":101,"width":68},{"name":"1/星7","x":116,"height":40,"y":101,"width":37},{"name":"1/星5","x":125,"height":57,"y":172,"width":56},{"name":"1/星8","x":183,"height":33,"y":219,"width":32},{"name":"1/星9","x":155,"height":37,"y":101,"width":36}],"height":256,"width":256} {"name":"right","SubTexture":[{"name":"1/勾","x":1,"height":112,"y":1,"width":128},{"name":"1/星1","x":196,"height":59,"y":72,"width":57},{"name":"1/星2","x":1,"height":45,"y":192,"width":43},{"name":"1/星3","x":131,"height":64,"y":72,"width":63},{"name":"1/星4","x":201,"height":45,"y":1,"width":45},{"name":"1/星6","x":131,"height":69,"y":1,"width":68},{"name":"1/星7","x":1,"height":40,"y":115,"width":37},{"name":"1/星5","x":196,"height":57,"y":133,"width":56},{"name":"1/星8","x":78,"height":33,"y":115,"width":32},{"name":"1/星9","x":40,"height":37,"y":115,"width":36}],"imagePath":"right_tex.png","height":256,"width":256}
\ No newline at end of file \ No newline at end of file
...@@ -18,12 +18,12 @@ ...@@ -18,12 +18,12 @@
"trimType": "auto", "trimType": "auto",
"trimThreshold": 1, "trimThreshold": 1,
"rotated": false, "rotated": false,
"offsetX": -13.5, "offsetX": -1,
"offsetY": 1.5, "offsetY": 9,
"trimX": 1, "trimX": 1,
"trimY": 1, "trimY": 1,
"width": 227, "width": 252,
"height": 251, "height": 236,
"rawWidth": 256, "rawWidth": 256,
"rawHeight": 256, "rawHeight": 256,
"borderTop": 0, "borderTop": 0,
......
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