Commit 93ad0fc2 authored by LWD's avatar LWD

代码提交

parent fb23390f
{
"ver": "1.1.0",
"uuid": "41ef287f-ba46-4313-a114-676b6eae4bca",
"subMetas": {}
}
\ No newline at end of file
...@@ -189,7 +189,7 @@ ...@@ -189,7 +189,7 @@
"array": [ "array": [
0, 0,
0, 0,
358.80515010544025, 234.6928844255829,
0, 0,
0, 0,
0, 0,
...@@ -804,7 +804,7 @@ ...@@ -804,7 +804,7 @@
"b": 77, "b": 77,
"a": 255 "a": 255
}, },
"_width": 3, "_width": 2,
"_id": "7frrmdk2NGMbzvXCwfUI+h" "_id": "7frrmdk2NGMbzvXCwfUI+h"
}, },
{ {
...@@ -2943,11 +2943,11 @@ ...@@ -2943,11 +2943,11 @@
"_dstBlendFactor": 771, "_dstBlendFactor": 771,
"_string": "telefe", "_string": "telefe",
"_N$string": "telefe", "_N$string": "telefe",
"_fontSize": 24, "_fontSize": 28,
"_lineHeight": 30, "_lineHeight": 32,
"_enableWrapText": false, "_enableWrapText": false,
"_N$file": { "_N$file": {
"__uuid__": "f0214b38-1b2a-41ef-aa3e-1d6949fd3b12" "__uuid__": "41ef287f-ba46-4313-a114-676b6eae4bca"
}, },
"_isSystemFontUsed": false, "_isSystemFontUsed": false,
"_spacingX": 0, "_spacingX": 0,
...@@ -3106,11 +3106,11 @@ ...@@ -3106,11 +3106,11 @@
"_dstBlendFactor": 771, "_dstBlendFactor": 771,
"_string": "telefe", "_string": "telefe",
"_N$string": "telefe", "_N$string": "telefe",
"_fontSize": 24, "_fontSize": 28,
"_lineHeight": 30, "_lineHeight": 32,
"_enableWrapText": false, "_enableWrapText": false,
"_N$file": { "_N$file": {
"__uuid__": "f0214b38-1b2a-41ef-aa3e-1d6949fd3b12" "__uuid__": "41ef287f-ba46-4313-a114-676b6eae4bca"
}, },
"_isSystemFontUsed": false, "_isSystemFontUsed": false,
"_spacingX": 0, "_spacingX": 0,
...@@ -3563,8 +3563,8 @@ ...@@ -3563,8 +3563,8 @@
}, },
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
"width": 90, "width": 130,
"height": 42.84 "height": 50
}, },
"_anchorPoint": { "_anchorPoint": {
"__type__": "cc.Vec2", "__type__": "cc.Vec2",
...@@ -3617,11 +3617,11 @@ ...@@ -3617,11 +3617,11 @@
"_dstBlendFactor": 771, "_dstBlendFactor": 771,
"_string": "telefe", "_string": "telefe",
"_N$string": "telefe", "_N$string": "telefe",
"_fontSize": 32, "_fontSize": 40,
"_lineHeight": 36, "_lineHeight": 44,
"_enableWrapText": false, "_enableWrapText": false,
"_N$file": { "_N$file": {
"__uuid__": "f0214b38-1b2a-41ef-aa3e-1d6949fd3b12" "__uuid__": "41ef287f-ba46-4313-a114-676b6eae4bca"
}, },
"_isSystemFontUsed": false, "_isSystemFontUsed": false,
"_spacingX": 0, "_spacingX": 0,
...@@ -3726,8 +3726,8 @@ ...@@ -3726,8 +3726,8 @@
}, },
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
"width": 90, "width": 130,
"height": 42.84 "height": 50
}, },
"_anchorPoint": { "_anchorPoint": {
"__type__": "cc.Vec2", "__type__": "cc.Vec2",
...@@ -3780,11 +3780,11 @@ ...@@ -3780,11 +3780,11 @@
"_dstBlendFactor": 771, "_dstBlendFactor": 771,
"_string": "telefe", "_string": "telefe",
"_N$string": "telefe", "_N$string": "telefe",
"_fontSize": 32, "_fontSize": 40,
"_lineHeight": 36, "_lineHeight": 44,
"_enableWrapText": false, "_enableWrapText": false,
"_N$file": { "_N$file": {
"__uuid__": "f0214b38-1b2a-41ef-aa3e-1d6949fd3b12" "__uuid__": "41ef287f-ba46-4313-a114-676b6eae4bca"
}, },
"_isSystemFontUsed": false, "_isSystemFontUsed": false,
"_spacingX": 0, "_spacingX": 0,
......
...@@ -2,261 +2,264 @@ ...@@ -2,261 +2,264 @@
* 游戏主逻辑 * 游戏主逻辑
*/ */
var game = cc.Class({ var game = cc.Class({
extends: cc.Component, extends: cc.Component,
properties: { properties: {
Item_0: { Item_0: {
default: [], default: [],
type: cc.Node, type: cc.Node,
displayName: "预制体" displayName: "预制体"
}, },
contentArr_2: { contentArr_2: {
default: [], default: [],
type: cc.Node, type: cc.Node,
displayName: "底下内容2" displayName: "底下内容2"
}, },
contentArr_1: { contentArr_1: {
default: [], default: [],
type: cc.Node, type: cc.Node,
displayName: "目标位置" displayName: "目标位置"
}, },
lb_title: { lb_title: {
default: null, default: null,
type: cc.Label, type: cc.Label,
displayName: "大标题" displayName: "大标题"
}, },
// btnList: { // btnList: {
// default: [], // default: [],
// type: cc.Button, // type: cc.Button,
// displayName: "上下页" // displayName: "上下页"
// }, // },
mask_node: { mask_node: {
default: null, default: null,
type: cc.Node, type: cc.Node,
displayName: "遮罩" displayName: "遮罩"
} }
}, },
ctor: function () { ctor: function () {
game.inst = this; game.inst = this;
g.game = game; g.game = game;
}, },
// 生命周期 onLoad // 生命周期 onLoad
onLoad() { onLoad() {
//初始化游戏 //初始化游戏
this.initGame(); this.initGame();
if (window.addEventListener) { if (window.addEventListener) {
window.addEventListener('resize', this.scaleEventCallBack, false) window.addEventListener('resize', this.scaleEventCallBack, false)
} else if (window.attachEvent) { } else if (window.attachEvent) {
window.attachEvent('resize', this.scaleEventCallBack, false) window.attachEvent('resize', this.scaleEventCallBack, false)
} }
}, },
//屏幕缩放 //屏幕缩放
scaleEventCallBack: function () { scaleEventCallBack: function () {
g.event_mgr.send("adjustUI"); g.event_mgr.send("adjustUI");
}, },
//初始化游戏 //初始化游戏
initGame: function () { initGame: function () {
//获得数据 //获得数据
g.res_mgr.getFormData(); g.res_mgr.getFormData();
}, },
setAABB(Id) { setAABB(Id) {
var node = this.contentArr_1[Id] var node = this.contentArr_1[Id]
let svLeftBottomPoint = node.parent.convertToWorldSpaceAR( let svLeftBottomPoint = node.parent.convertToWorldSpaceAR(
cc.v2( cc.v2(
node.x - node.anchorX * node.width / 2, node.x - node.anchorX * node.width / 2,
node.y - node.anchorY * node.height / 2 node.y - node.anchorY * node.height / 2
) )
); );
// 求出 ScrollView 可视区域在世界坐标系中的矩形(碰撞盒) // 求出 ScrollView 可视区域在世界坐标系中的矩形(碰撞盒)
let svBBoxRect = cc.rect( let svBBoxRect = cc.rect(
svLeftBottomPoint.x - 60, svLeftBottomPoint.x - 120,
svLeftBottomPoint.y - 30, svLeftBottomPoint.y - 100,
node.width, node.width,
node.height node.height
); );
// console.log(Id + ":" + svLeftBottomPoint.x + "," + svLeftBottomPoint.y); // console.log(Id + ":" + svLeftBottomPoint.x + "," + svLeftBottomPoint.y);
return svBBoxRect return svBBoxRect
}, },
//检查当前缩放倍数 //检查当前缩放倍数
checkScale: function (num) { checkScale: function (num) {
var scale = 1; var scale = 1;
if (num > 2 && num <= 4) { if (num > 2 && num <= 4) {
scale = 0.74 scale = 0.74
} }
if (num > 4) { if (num > 4) {
scale = 0.65 scale = 0.65
} }
return scale; return scale;
}, },
//添加节点 //添加节点
addItem: function () { addItem: function () {
let itemArr = g.data_mgr.getSheepArr(); let itemArr = g.data_mgr.getSheepArr();
this.idx = this.checkNodeParent(); this.idx = this.checkNodeParent();
g.data_mgr.nowNum = itemArr.length; g.data_mgr.nowNum = itemArr.length;
for (var i = 0; i < itemArr.length; i++) { itemArr.sort(function () { return Math.random() > 0.5 ? -1 : 1; })
let newItem_0 = cc.instantiate(this.Item_0[itemArr.length > 14 ? 0 : 1]);
//let newItem_1 = cc.instantiate(this.Item_1); for (var i = 0; i < itemArr.length; i++) {
//更新子项 let newItem_0 = cc.instantiate(this.Item_0[itemArr.length > 14 ? 0 : 1]);
var com = newItem_0.getChildByName("item").getComponent("item");
let itemInfo = itemArr[i]; //let newItem_1 = cc.instantiate(this.Item_1);
com.updateUI(itemInfo); //更新子项
newItem_0.active = true; var com = newItem_0.getChildByName("item").getComponent("item");
// newItem_1.active = true; let itemInfo = itemArr[i];
//设置类别 com.updateUI(itemInfo);
let sheepInfo = g.data_mgr.getSheep(i); newItem_0.active = true;
newItem_0.getChildByName("item").type = this.checkType(sheepInfo.sheepfoldId); // newItem_1.active = true;
// newItem_1.parent = newItem_0; //设置类别
// newItem_0.parent = this.contentArr; let sheepInfo = g.data_mgr.getSheep(i);
// var idx = this.checkNodeParent(i); newItem_0.getChildByName("item").type = this.checkType(sheepInfo.sheepfoldId);
// newItem_1.parent = newItem_0;
newItem_0.parent = this.contentArr_2[this.idx]; // newItem_0.parent = this.contentArr;
}; // var idx = this.checkNodeParent(i);
},
newItem_0.parent = this.contentArr_2[this.idx];
//检测放到哪个节点底下 };
checkNodeParent: function () { },
//获取到总列表
var itemArr = g.data_mgr.getSheepArr(); //检测放到哪个节点底下
checkNodeParent: function () {
// //获取到总列表
if (itemArr.length <= 7) { var itemArr = g.data_mgr.getSheepArr();
this.contentArr_2[1].active = true;
var idx = 1; //
} else { if (itemArr.length <= 7) {
this.contentArr_2[0].active = true; this.contentArr_2[1].active = true;
var idx = 0; var idx = 1;
} } else {
return idx; this.contentArr_2[0].active = true;
}, var idx = 0;
}
//检查类别 return idx;
checkType: function (Id) { },
for (var i in g.data_mgr.getSheepfoldArr()) {
var sheepfoldInfo = g.data_mgr.getSheepfoldArr()[i]; //检查类别
if (Id == sheepfoldInfo.id) { checkType: function (Id) {
return ~~i + 1; for (var i in g.data_mgr.getSheepfoldArr()) {
} var sheepfoldInfo = g.data_mgr.getSheepfoldArr()[i];
} if (Id == sheepfoldInfo.id) {
return -1; return ~~i + 1;
}, }
}
//更新界面信息 return -1;
UpdataUi: function () { },
//设置大标题
this.lb_title.string = g.data_mgr.getTitle(); //更新界面信息
//设置俩个标题 UpdataUi: function () {
this.contentArr_1[0].getChildByName("title").getComponent(cc.Label).string = g.data_mgr.getSheepfold(0).word; //设置大标题
//设置俩个标题 this.lb_title.string = g.data_mgr.getTitle();
this.contentArr_1[1].getChildByName("title").getComponent(cc.Label).string = g.data_mgr.getSheepfold(1).word; //设置俩个标题
this.contentArr_1[0].getChildByName("title").getComponent(cc.Label).string = g.data_mgr.getSheepfold(0).word;
//重置UI界面 //设置俩个标题
this.resetUI(); this.contentArr_1[1].getChildByName("title").getComponent(cc.Label).string = g.data_mgr.getSheepfold(1).word;
//添加项
this.addItem(); //重置UI界面
this.resetUI();
// //设置上下页按钮状态 //添加项
// this.setButtonState(); this.addItem();
},
// //设置上下页按钮状态
//重置UI界面 // this.setButtonState();
resetUI: function () { },
//移除所有子节点
this.contentArr_2[0].removeAllChildren(); //重置UI界面
this.contentArr_2[1].removeAllChildren(); resetUI: function () {
this.contentArr_1[0].getChildByName("connent_3").getChildByName("Layout").removeAllChildren(); //移除所有子节点
this.contentArr_1[1].getChildByName("connent_3").getChildByName("Layout").removeAllChildren(); this.contentArr_2[0].removeAllChildren();
}, this.contentArr_2[1].removeAllChildren();
this.contentArr_1[0].getChildByName("connent_3").getChildByName("Layout").removeAllChildren();
//重新开始 this.contentArr_1[1].getChildByName("connent_3").getChildByName("Layout").removeAllChildren();
onBtnReStart: function () { },
g.speaker.inst.play_btn();
//移除所有计时器 //重新开始
this.unscheduleAllCallbacks(); onBtnReStart: function () {
//初始化界面 g.speaker.inst.play_btn();
this.UpdataUi(); //移除所有计时器
g.speaker.inst.play_restart(); this.unscheduleAllCallbacks();
}, //初始化界面
this.UpdataUi();
//游戏开始 g.speaker.inst.play_restart();
gameStart: function () { },
console.log("游戏开始:" + g.data_mgr);
//播放一个上面的音乐 //游戏开始
this.setAudioInfo(1); gameStart: function () {
}, console.log("游戏开始:" + g.data_mgr);
//播放一个上面的音乐
//设置上下页按钮状态 this.setAudioInfo(1);
setButtonState: function () { },
//先判断题目长度
if (g.data_mgr.data.contentObj.pageArr.length < 2) { //设置上下页按钮状态
this.btnList[0].node.active = false; setButtonState: function () {
this.btnList[1].node.active = false; //先判断题目长度
} else { if (g.data_mgr.data.contentObj.pageArr.length < 2) {
//如果第一页 this.btnList[0].node.active = false;
if (g.data_mgr.pageId == 0) { this.btnList[1].node.active = false;
this.btnList[1].node.active = true; } else {
this.btnList[0].node.active = false; //如果第一页
} if (g.data_mgr.pageId == 0) {
if (g.data_mgr.pageId == g.data_mgr.data.contentObj.pageArr.length - 1) { this.btnList[1].node.active = true;
this.btnList[0].node.active = true; this.btnList[0].node.active = false;
this.btnList[1].node.active = false; }
} if (g.data_mgr.pageId == g.data_mgr.data.contentObj.pageArr.length - 1) {
if (g.data_mgr.pageId > 0 && g.data_mgr.pageId < g.data_mgr.data.contentObj.pageArr.length - 1) { this.btnList[0].node.active = true;
this.btnList[0].node.active = true; this.btnList[1].node.active = false;
this.btnList[1].node.active = true; }
} if (g.data_mgr.pageId > 0 && g.data_mgr.pageId < g.data_mgr.data.contentObj.pageArr.length - 1) {
} this.btnList[0].node.active = true;
}, this.btnList[1].node.active = true;
}
//上一关 }
onBtnLastPage: function () { },
g.speaker.inst.play_btn();
//上一关
if (g.data_mgr.pageId - 1 >= 0) { onBtnLastPage: function () {
g.data_mgr.pageId -= 1; g.speaker.inst.play_btn();
this.setButtonState();
this.onBtnReStart(); if (g.data_mgr.pageId - 1 >= 0) {
} g.data_mgr.pageId -= 1;
}, this.setButtonState();
this.onBtnReStart();
//下一关 }
onBtnNextPage: function () { },
g.speaker.inst.play_btn();
//下一关
if (g.data_mgr.pageId + 1 < g.data_mgr.data.contentObj.pageArr.length) { onBtnNextPage: function () {
g.data_mgr.pageId += 1; g.speaker.inst.play_btn();
this.setButtonState();
this.onBtnReStart(); if (g.data_mgr.pageId + 1 < g.data_mgr.data.contentObj.pageArr.length) {
} g.data_mgr.pageId += 1;
}, this.setButtonState();
this.onBtnReStart();
}
onBtnMask: function () { },
if (this.isLoadEnd) {
this.isLoadEnd = false;
g.speaker.inst.play_start(() => { onBtnMask: function () {
setTimeout(() => { if (this.isLoadEnd) {
g.game.inst.playAudioTitle(() => { this.isLoadEnd = false;
g.game.inst.mask_node.active = false; g.speaker.inst.play_start(() => {
//游戏开始 setTimeout(() => {
g.game.inst.gameStart(); g.game.inst.playAudioTitle(() => {
}); g.game.inst.mask_node.active = false;
}, 500) //游戏开始
}); g.game.inst.gameStart();
} });
}, }, 500)
});
}
},
}); });
...@@ -3,252 +3,252 @@ ...@@ -3,252 +3,252 @@
*/ */
cc.Class({ cc.Class({
extends: cc.Component, extends: cc.Component,
properties: { properties: {
Item_name: { Item_name: {
default: null, default: null,
type: cc.Label, type: cc.Label,
displayName: "名字" displayName: "名字"
}, },
Item_redName: { Item_redName: {
default: null, default: null,
type: cc.Label, type: cc.Label,
displayName: "红色名字" displayName: "红色名字"
}, },
Item_photo: { Item_photo: {
default: null, default: null,
type: cc.Node, type: cc.Node,
displayName: "图片" displayName: "图片"
}, },
Item_complete: { Item_complete: {
default: null, default: null,
type: cc.Node, type: cc.Node,
displayName: "完成显示" displayName: "完成显示"
}, },
}, },
start: function () { start: function () {
this.node.on(cc.Node.EventType.TOUCH_START, this.touchBegan, this); this.node.on(cc.Node.EventType.TOUCH_START, this.touchBegan, this);
this.node.on(cc.Node.EventType.TOUCH_MOVE, this.touchMove, this); this.node.on(cc.Node.EventType.TOUCH_MOVE, this.touchMove, this);
this.node.on(cc.Node.EventType.TOUCH_END, this.touchEnd, this); this.node.on(cc.Node.EventType.TOUCH_END, this.touchEnd, this);
this.node.on(cc.Node.EventType.TOUCH_CANCEL, this.touchCancel, this); this.node.on(cc.Node.EventType.TOUCH_CANCEL, this.touchCancel, this);
}, },
//触摸开始 //触摸开始
touchBegan: function (event) { touchBegan: function (event) {
this.isMove = false; this.isMove = false;
this.deltaPos = this.node.x + this.node.y; this.deltaPos = this.node.x + this.node.y;
}, },
//触摸移动 //触摸移动
touchMove: function (event) { touchMove: function (event) {
if (this.node.isComplent) { if (this.node.isComplent) {
return return
} }
// var posScreen = event.getLocation(); //点击事件获取位置 // var posScreen = event.getLocation(); //点击事件获取位置
// var posNode = this.node.parent.convertToNodeSpaceAR(posScreen); // var posNode = this.node.parent.convertToNodeSpaceAR(posScreen);
// var iposTouch = this.getFormatIPos(posNode); // var iposTouch = this.getFormatIPos(posNode);
var delta = event.getDelta(); var delta = event.getDelta();
this.node.x += delta.x; this.node.x += delta.x;
this.node.y += delta.y; this.node.y += delta.y;
var deltaPos = this.node.x + this.node.y; var deltaPos = this.node.x + this.node.y;
if (Math.abs(this.deltaPos - deltaPos) > 10) { if (Math.abs(this.deltaPos - deltaPos) > 10) {
this.isMove = true; this.isMove = true;
} }
}, },
//触摸结束 //触摸结束
touchEnd: function (event) { touchEnd: function (event) {
//获得世界坐标 //获得世界坐标
var posScreen = event.getLocation(); //点击事件获取位置 var posScreen = event.getLocation(); //点击事件获取位置
var posNode = this.node.convertToNodeSpaceAR(posScreen); var posNode = this.node.convertToNodeSpaceAR(posScreen);
console.log("世界坐标" + posNode); console.log("世界坐标" + posNode);
if (!this.isMove) { if (!this.isMove) {
cc.log("点击了"); cc.log("点击了");
this.onBtnRotate(); this.onBtnRotate();
//回到原来的位置 //回到原来的位置
this.node.x = 0; this.node.x = 0;
this.node.y = 0; this.node.y = 0;
return return
} }
//获得俩个节点的世界坐标 //获得俩个节点的世界坐标
var contentArrPos_0 = g.game.inst.setAABB(0); var contentArrPos_0 = g.game.inst.setAABB(0);
var contentArrPos_1 = g.game.inst.setAABB(1); var contentArrPos_1 = g.game.inst.setAABB(1);
// 获取 ScrollView Node 的左下角坐标在世界坐标系中的坐标 // 获取 ScrollView Node 的左下角坐标在世界坐标系中的坐标
let svLeftBottomPoint = this.node.parent.convertToWorldSpaceAR( let svLeftBottomPoint = this.node.parent.convertToWorldSpaceAR(
cc.v2( cc.v2(
this.node.x - this.node.anchorX * this.node.width, this.node.x - this.node.anchorX * this.node.width,
this.node.y - this.node.anchorY * this.node.height this.node.y - this.node.anchorY * this.node.height
) )
); );
// 求出 ScrollView 可视区域在世界坐标系中的矩形(碰撞盒) // 求出 ScrollView 可视区域在世界坐标系中的矩形(碰撞盒)
var posNode_1 = cc.rect( var posNode_1 = cc.rect(
svLeftBottomPoint.x, svLeftBottomPoint.x,
svLeftBottomPoint.y, svLeftBottomPoint.y,
this.node.width, this.node.width,
this.node.height this.node.height
); );
var isIntersect_1 = contentArrPos_1.containsRect(posNode_1);//判断是否被包含 var isIntersect_1 = contentArrPos_1.containsRect(posNode_1);//判断是否被包含
var isIntersect_0 = contentArrPos_0.containsRect(posNode_1); var isIntersect_0 = contentArrPos_0.containsRect(posNode_1);
// console.log("坐标" + svLeftBottomPoint.x + "," + svLeftBottomPoint.y + "是否包含" + isIntersect_1); // console.log("坐标" + svLeftBottomPoint.x + "," + svLeftBottomPoint.y + "是否包含" + isIntersect_1);
if (isIntersect_1) { if (isIntersect_1) {
if (this.node.type == 1) { if (this.node.type == 1) {
this.Item_complete.active = true; this.Item_complete.active = true;
this.node.isComplent = true; this.node.isComplent = true;
g.data_mgr.nowNum -= 1; g.data_mgr.nowNum -= 1;
if (g.data_mgr.nowNum == 0) { if (g.data_mgr.nowNum == 0) {
g.effect.inst.showEffect2(); g.effect.inst.showEffect2();
} }
g.speaker.inst.play_good(); g.speaker.inst.play_good();
var newItem_temp = cc.instantiate(g.game.inst.Item_0[2]); var newItem_temp = cc.instantiate(g.game.inst.Item_0[2]);
g.game.inst.contentArr_1[1].getChildByName("db").active = true; g.game.inst.contentArr_1[1].getChildByName("db").active = true;
g.game.inst.contentArr_1[1].getChildByName("db").getComponent(dragonBones.ArmatureDisplay).playAnimation("newAnimation", 1); g.game.inst.contentArr_1[1].getChildByName("db").getComponent(dragonBones.ArmatureDisplay).playAnimation("newAnimation", 1);
if (g.game.inst.idx == 1) { if (g.game.inst.idx == 1) {
this.node.scale = 0.666; this.node.scale = 0.666;
this.node.x = 0; this.node.x = 0;
} }
this.node.parent = newItem_temp; this.node.parent = newItem_temp;
newItem_temp.parent = g.game.inst.contentArr_1[1].getChildByName("connent_3").getChildByName("Layout"); newItem_temp.parent = g.game.inst.contentArr_1[1].getChildByName("connent_3").getChildByName("Layout");
this.node.x = 0; this.node.x = 0;
this.node.y = 0; this.node.y = 0;
} }
else { else {
this.errorEffect(); this.errorEffect();
} }
console.log("被1包含" + isIntersect_1); console.log("被1包含" + isIntersect_1);
} else } else
if (isIntersect_0) { if (isIntersect_0) {
if (this.node.type == 2) { if (this.node.type == 2) {
this.Item_complete.active = true; this.Item_complete.active = true;
this.node.isComplent = true; this.node.isComplent = true;
g.data_mgr.nowNum -= 1; g.data_mgr.nowNum -= 1;
if (g.data_mgr.nowNum == 0) { if (g.data_mgr.nowNum == 0) {
g.effect.inst.showEffect2(); g.effect.inst.showEffect2();
} }
g.speaker.inst.play_good(); g.speaker.inst.play_good();
var newItem_temp = cc.instantiate(g.game.inst.Item_0[2]); var newItem_temp = cc.instantiate(g.game.inst.Item_0[2]);
g.game.inst.contentArr_1[0].getChildByName("db").active = true; g.game.inst.contentArr_1[0].getChildByName("db").active = true;
g.game.inst.contentArr_1[0].getChildByName("db").getComponent(dragonBones.ArmatureDisplay).playAnimation("newAnimation", 1); g.game.inst.contentArr_1[0].getChildByName("db").getComponent(dragonBones.ArmatureDisplay).playAnimation("newAnimation", 1);
if (g.game.inst.idx == 1) { if (g.game.inst.idx == 1) {
this.node.scale = 0.666; this.node.scale = 0.666;
this.node.x = 0; this.node.x = 0;
} }
this.node.parent = newItem_temp; this.node.parent = newItem_temp;
newItem_temp.parent = g.game.inst.contentArr_1[0].getChildByName("connent_3").getChildByName("Layout"); newItem_temp.parent = g.game.inst.contentArr_1[0].getChildByName("connent_3").getChildByName("Layout");
this.node.x = 0; this.node.x = 0;
this.node.y = 0; this.node.y = 0;
console.log("被2包含" + isIntersect_0); console.log("被2包含" + isIntersect_0);
} }
else { else {
this.errorEffect(); this.errorEffect();
} }
} }
else { else {
//回到原来的位置 //回到原来的位置
this.node.x = 0; this.node.x = 0;
this.node.y = 0; this.node.y = 0;
} }
}, },
errorEffect: function () { errorEffect: function () {
g.speaker.inst.play_error(); g.speaker.inst.play_error();
this.node.getChildByName("red").active = true; this.node.getChildByName("red").active = true;
cc.tween(this.node) cc.tween(this.node)
.to(0.1, { scaleY: 0.9, scaleX: 1.1 }) .to(0.1, { scaleY: 0.9, scaleX: 1.1 })
.to(0.15, { scaleY: 1.1, scaleX: 0.9 }) .to(0.15, { scaleY: 1.1, scaleX: 0.9 })
.to(0.1, { scaleY: 1, scaleX: 1 }) .to(0.1, { scaleY: 1, scaleX: 1 })
.start() .start()
setTimeout(() => { setTimeout(() => {
this.node.getChildByName("red").active = false; this.node.getChildByName("red").active = false;
//回到原来的位置 //回到原来的位置
this.node.x = 0; this.node.x = 0;
this.node.y = 0; this.node.y = 0;
}, 500) }, 500)
}, },
//触摸取消 //触摸取消
touchCancel: function (event) { touchCancel: function (event) {
//回到原来的位置 //回到原来的位置
this.node.x = 0; this.node.x = 0;
this.node.y = 0; this.node.y = 0;
this.isMove = false; this.isMove = false;
}, },
//更新界面ui //更新界面ui
updateUI: function (Info) { updateUI: function (Info) {
//当前数据 //当前数据
this.itemInfo = Info; this.itemInfo = Info;
//初始化数据 //初始化数据
this.InitData(); this.InitData();
//是否已经完成了 //是否已经完成了
this.node.isComplent = false; this.node.isComplent = false;
}, },
//点击翻面 //点击翻面
onBtnRotate: function () { onBtnRotate: function () {
//翻面音效 //翻面音效
g.speaker.inst.play_btn(); g.speaker.inst.play_btn();
var scaleX = this.node.scaleY; var scaleX = this.node.scaleY;
cc.tween(this.node) cc.tween(this.node)
.to(0.3, { scaleX: 0 }) .to(0.3, { scaleX: 0 })
.call(() => { .call(() => {
if (this.Item_name.node.active) { if (this.Item_name.node.active) {
this.Item_name.node.active = false; this.Item_name.node.active = false;
this.Item_photo.active = true; this.Item_photo.active = true;
this.Item_redName.active = false; this.Item_redName.node.active = false;
} else { } else {
this.Item_name.node.active = true; this.Item_name.node.active = true;
this.Item_photo.active = false; this.Item_photo.active = false;
this.Item_redName.active = true; this.Item_redName.node.active = true;
} }
}) })
.to(0.3, { scaleX: scaleX }) .to(0.3, { scaleX: scaleX })
.start(); .start();
}, },
//初始化信息 //初始化信息
InitData: function () { InitData: function () {
//设置图片 //设置图片
g.res_mgr.getSpriteFrimeByUrl(this.itemInfo.picUrl, (list) => { g.res_mgr.getSpriteFrimeByUrl(this.itemInfo.picUrl, (list) => {
this.Item_photo.getComponent(cc.Sprite).spriteFrame = list; this.Item_photo.getComponent(cc.Sprite).spriteFrame = list;
this.photoScare(this.Item_photo, g.game.inst.idx); this.photoScare(this.Item_photo, g.game.inst.idx);
// this.photoScare(this.nodeState[2].getChildByName("spt_item"), 1); // this.photoScare(this.nodeState[2].getChildByName("spt_item"), 1);
}); });
//设置名字 //设置名字
this.Item_name.string = this.itemInfo.word; this.Item_name.string = this.itemInfo.word;
//设置红色名字 //设置红色名字
this.Item_redName.string = this.itemInfo.word; this.Item_redName.string = this.itemInfo.word;
}, },
//图片适配 //图片适配
photoScare: function (node, type) { photoScare: function (node, type) {
var maxNum = type == 0 ? 50 : 75; var maxNum = type == 0 ? 50 : 75;
let maxSize = Math.min(maxNum / node.height, maxNum / node.width); let maxSize = Math.min(maxNum / node.height, maxNum / node.width);
if (node.perScale == undefined) { if (node.perScale == undefined) {
node.perScale = node.scaleX; node.perScale = node.scaleX;
} else { } else {
node.scaleX = node.perScale; node.scaleX = node.perScale;
node.scaleY = node.perScale; node.scaleY = node.perScale;
} }
node.scaleX *= maxSize; node.scaleX *= maxSize;
node.scaleY *= maxSize; node.scaleY *= maxSize;
}, },
}); });
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