Commit 4d9f0709 authored by Tt's avatar Tt

基础卡片完成 开始调整游戏效果

parent 7c2d2857
......@@ -28,5 +28,26 @@ class Ani {
tween.start();
})
}
static flipX0(item) {
return new Promise((resolve) => {
let itemScale = item.scaleY;
item.scaleX = itemScale;
let tween = cc.tween(item);
tween.to(0.2, { scaleX: 0 })
.call(() => { resolve() });
tween.start();
})
}
static flipX1(item) {
return new Promise((resolve) => {
let itemScale = item.scaleY;
item.scaleX = 0;
let tween = cc.tween(item);
tween.to(0.2, { scaleX: itemScale })
.call(() => { resolve() });
tween.start();
})
}
}
export default Ani;
\ No newline at end of file
......@@ -16,9 +16,9 @@ class Card {
}
}
class defClass {
constructor(id, title, dep) {
constructor(id, title, type) {
this.id = id;
this.dep = dep;
this.type = type;
this.title = title;
this.child = [];
}
......@@ -131,7 +131,13 @@ class GameManager {
radioValue: "A"
}
]
},
}
]
},
{
id: 10,
title: "fenlei2",
child: [
{
id: 101,
title: "sonlei3",
......@@ -161,13 +167,7 @@ class GameManager {
radioValue: "A"
}
]
}
]
},
{
id: 10,
title: "fenlei2",
child: [
},
{
id: 201,
title: "sonlei4",
......@@ -273,12 +273,12 @@ class GameManager {
let zhuleiClass = new defClass(zhulei.id, zhulei.title, 0);
for (let a = 0; a < zhulei.child.length; a++) {
let fenlei = zhulei.child[a];
let fenleiClass = new defClass(fenId, fenlei.title, 1);
let fenleiClass = new defClass(fenId, fenlei.title, 0);
fenId++;//只有1和2
for (let b = 0; b < fenlei.child.length; b++) {
sonId++;
let sonlei = fenlei.child[b];
let sonleiClass = new defClass(sonId, sonlei.title, 2);
let sonleiClass = new defClass(sonId, sonlei.title, a);
for (let c = 0; c < sonlei.child.length; c++) {
let card = sonlei.child[c];
cardId++;
......
This diff is collapsed.
......@@ -142,18 +142,6 @@ cc.Class({
//全局游戏
_gameCode: null,
initData() {
......@@ -204,34 +192,49 @@ cc.Class({
pg.view.setString(pg.view.find(this, "box/sub_0/txt"), this._zhuClass.child[0].title);
pg.view.setString(pg.view.find(this, "box/sub_1/txt"), this._zhuClass.child[1].title);
this.initSon();
this.initLine();
this.initBox();
this.initItems();
},
initSon() {
//刷新子类
let son = pg.view.find(this, "box/son_0");
let box = pg.view.find(this, "box");
let fenlei1 = this._zhuClass.child[0];
let fenlei2 = this._zhuClass.child[1];
let sonleis = fenlei1.child.concat(fenlei2.child);
let item = pg.view.find(this, "box/son_0");
let parent = pg.view.find(this, "box");
let list1 = this._zhuClass.child[0];
let list2 = this._zhuClass.child[1];
let list = list1.child.concat(list2.child);
let x = -480;//-291.057
let addX = 190;
let y = 75;
for (let i = 0; i < sonleis.length; i++) {
let data = sonleis[i];
let sonClone = cc.instantiate(son);
sonClone.active = true;
for (let i = 0; i < list.length; i++) {
let data = list[i];
let itemClone = cc.instantiate(item);
itemClone.active = true;
let posX = x + addX * i;
let posY = y;
sonClone.x = posX;
sonClone.y = posY;
sonClone.data = data;
pg.view.setString(pg.view.find(sonClone, "txt"), data.title);
box.addChild(sonClone);
itemClone.x = posX;
itemClone.y = posY;
itemClone.data = data;
pg.view.setString(pg.view.find(itemClone, "txt"), data.title);
pg.view.visible(pg.view.find(itemClone, "bg_blue"), data.type == 0);
pg.view.visible(pg.view.find(itemClone, "bg_green"), data.type == 1);
parent.addChild(itemClone);
}
},
initLine() {
//刷新子类
let parent = pg.view.find(this, "line");
let list1 = this._zhuClass.child[0];
let list2 = this._zhuClass.child[1];
let list = list1.child.concat(list2.child);
//0 1 00 11
pg.view.visible(pg.view.find(parent, "line2/line0"), list[2].type == 0);
pg.view.visible(pg.view.find(parent, "line2/line1"), list[2].type == 1);
pg.view.visible(pg.view.find(parent, "line3/line0"), list[3].type == 1);
pg.view.visible(pg.view.find(parent, "line3/line1"), list[3].type == 0);
},
initBox() {
this._boxItems = [];
//刷新子类
......@@ -276,6 +279,11 @@ cc.Class({
sonClone.x = posX;
sonClone.y = posY;
this.initButton(sonClone);
let icon = sonClone.getChildByName("icon");
let txt = sonClone.getChildByName("txt");
icon.active = false;
txt.active = true;
pg.view.setString(txt, data.txt);
box.addChild(sonClone);
}
} else {
......@@ -297,6 +305,11 @@ cc.Class({
sonClone.scaleX = scale;
sonClone.scaleY = scale;
this.initButton(sonClone);
let icon = sonClone.getChildByName("icon");
let txt = sonClone.getChildByName("txt");
icon.active = false;
txt.active = true;
pg.view.setString(txt, data.txt);
box.addChild(sonClone);
}
}
......@@ -309,41 +322,88 @@ cc.Class({
item.on(cc.Node.EventType.TOUCH_CANCEL, this.onCancelItem, this);
},
onStartItem(touch) {
//判断是否是在原地并没有到处移动
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;
//有点击行为不进行位移
// let touchPos = touch.getLocation();
// touch.target.x = touchPos.x - 1280 / 2;
// touch.target.y = touchPos.y - 720 / 2;
},
onEndItem(touch) {
let item = touch.target;
let touchPos = touch.getLocation();
//判断是否是在原地并没有到处移动
if (this.checkCollider({
x: touchPos.x - 1280 / 2,
y: touchPos.y - 720 / 2
}, {
x: this._startPos.x,
y: this._startPos.y,
width: 50,//item.width,
height: 50,//item.height
})) {
//回归原位
item.x = this._startPos.x;
item.y = this._startPos.y;
//变换动画
ani.flipX0(item).then(() => {
let icon = item.getChildByName("icon");
let txt = item.getChildByName("txt");
if (txt.active) {
icon.active = true;
txt.active = false;
} else {
icon.active = false;
txt.active = true;
}
ani.flipX1(item);
})
return;
}
//检测碰撞
let box = this.getCollider(touch.target);
let box = this.getCollider(item);
if (box) {
//成功 失败的判断 根据id
let successed = box.data.child.some(dt => dt.cardId == touch.target.data.cardId);
let successed = box.data.child.some(dt => dt.cardId == item.data.cardId);
if (successed) {
alert("成功")
} else {
alert("失败")
//碰撞失败退回原位置
touch.target.x = this._startPos.x;
touch.target.y = this._startPos.y;
item.x = this._startPos.x;
item.y = this._startPos.y;
}
} else {
//碰撞失败退回原位置
touch.target.x = this._startPos.x;
touch.target.y = this._startPos.y;
item.x = this._startPos.x;
item.y = this._startPos.y;
}
},
onMoveItem(touch) {
//获取到的location是 当前点击的位置 而不是按钮原本应该所在的位置。
let touchPos = touch.getLocation();
let item = touch.target;
//判断是否是在原地并没有到处移动
if (this.checkCollider({
x: touchPos.x - 1280 / 2,
y: touchPos.y - 720 / 2
}, {
x: this._startPos.x,
y: this._startPos.y,
width: 30,//item.width,
height: 30,//item.height
})) {
return;
}
touch.target.x = touchPos.x - 1280 / 2;
touch.target.y = touchPos.y - 720 / 2;
},
onCancelItem(touch) {
console.log(touch);
//碰撞失败退回原位置
touch.target.x = this._startPos.x;
touch.target.y = this._startPos.y;
},
getCollider(item) {
for (let i = 0; i < this._boxItems.length; i++) {
......@@ -363,6 +423,62 @@ cc.Class({
// updateItem(item, data) {
// let img = pg.view.find(item, `img`);
// let txt = pg.view.find(item, `txt`);
......
{
"ver": "2.3.5",
"uuid": "2642bc88-a42b-4b01-8393-900c0a1dadb0",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 150,
"height": 80,
"platformSettings": {},
"subMetas": {
"chose": {
"ver": "1.0.4",
"uuid": "86d42669-be71-4333-a47a-e75f1d141a5c",
"rawTextureUuid": "2642bc88-a42b-4b01-8393-900c0a1dadb0",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 150,
"height": 80,
"rawWidth": 150,
"rawHeight": 80,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "12290598-9ea6-4e9f-b0db-8a9b6dd0033e",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 154,
"height": 86,
"platformSettings": {},
"subMetas": {
"fail": {
"ver": "1.0.4",
"uuid": "104f34e0-1777-4bd6-ba34-c0c1da5a0882",
"rawTextureUuid": "12290598-9ea6-4e9f-b0db-8a9b6dd0033e",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 154,
"height": 86,
"rawWidth": 154,
"rawHeight": 86,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "b1a260cf-fa78-4b47-be0b-9b950b896d10",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 124,
"height": 47,
"platformSettings": {},
"subMetas": {
"success": {
"ver": "1.0.4",
"uuid": "efc40866-ef82-4fac-b41b-99795e03cf96",
"rawTextureUuid": "b1a260cf-fa78-4b47-be0b-9b950b896d10",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 124,
"height": 47,
"rawWidth": 124,
"rawHeight": 47,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "1.1.2",
"uuid": "40cd2209-7806-404c-998a-e8c7e1ded86f",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "2d690ccf-e2b6-4a1e-a8aa-3911a5aa11bd",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 87,
"height": 85,
"platformSettings": {},
"subMetas": {
"combined-shape-copy-2": {
"ver": "1.0.4",
"uuid": "46aaad2d-77df-45d6-ab63-a80468d0330a",
"rawTextureUuid": "2d690ccf-e2b6-4a1e-a8aa-3911a5aa11bd",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 87,
"height": 85,
"rawWidth": 87,
"rawHeight": 85,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "84678017-3e2d-4644-a49e-b9472cc9b73c",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 203,
"height": 51,
"platformSettings": {},
"subMetas": {
"combined-shape-copy-3": {
"ver": "1.0.4",
"uuid": "41069ac1-9cb1-4f02-a98a-19a4f17af6e2",
"rawTextureUuid": "84678017-3e2d-4644-a49e-b9472cc9b73c",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 203,
"height": 51,
"rawWidth": 203,
"rawHeight": 51,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "9365ddf4-78a9-45ef-9560-00f3c1b4478a",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 102,
"height": 104,
"platformSettings": {},
"subMetas": {
"combined-shape": {
"ver": "1.0.4",
"uuid": "a79ec948-2c32-4d8a-9de5-72756c0c8603",
"rawTextureUuid": "9365ddf4-78a9-45ef-9560-00f3c1b4478a",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 102,
"height": 104,
"rawWidth": 102,
"rawHeight": 104,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "2154aa82-ff09-4fe2-8ffe-61617746bad1",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 116,
"height": 117,
"platformSettings": {},
"subMetas": {
"combined-shape_2": {
"ver": "1.0.4",
"uuid": "a47191ae-c423-4c09-982c-291a9ffeb0da",
"rawTextureUuid": "2154aa82-ff09-4fe2-8ffe-61617746bad1",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 116,
"height": 117,
"rawWidth": 116,
"rawHeight": 117,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "fa2150de-2701-4f3a-9a7b-196b81d7131c",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 153,
"height": 86,
"platformSettings": {},
"subMetas": {
"group-5": {
"ver": "1.0.4",
"uuid": "8fef2fd6-a702-461f-955d-6c2d8f4b2677",
"rawTextureUuid": "fa2150de-2701-4f3a-9a7b-196b81d7131c",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 153,
"height": 86,
"rawWidth": 153,
"rawHeight": 86,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "fb561a78-2e2b-48ae-8a18-d70fc0745e3a",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 152,
"height": 85,
"platformSettings": {},
"subMetas": {
"group-6": {
"ver": "1.0.4",
"uuid": "48a4a851-1ce1-4e02-be55-229591cf3e36",
"rawTextureUuid": "fb561a78-2e2b-48ae-8a18-d70fc0745e3a",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 152,
"height": 85,
"rawWidth": 152,
"rawHeight": 85,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "e98b3336-1e04-4a4e-be74-9b61067904dd",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 15,
"height": 70,
"platformSettings": {},
"subMetas": {
"rectangle-40": {
"ver": "1.0.4",
"uuid": "f9c94281-5c01-40d5-92fb-65fb17349815",
"rawTextureUuid": "e98b3336-1e04-4a4e-be74-9b61067904dd",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 15,
"height": 70,
"rawWidth": 15,
"rawHeight": 70,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
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