Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
LWD_2
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
template admin
LWD_2
Commits
93ad0fc2
Commit
93ad0fc2
authored
Jun 16, 2021
by
LWD
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
代码提交
parent
fb23390f
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
532 additions
and
523 deletions
+532
-523
华文圆体 REGULAR.TTF
play/assets/resources/font/华文圆体 REGULAR.TTF
+0
-0
华文圆体 REGULAR.TTF.meta
play/assets/resources/font/华文圆体 REGULAR.TTF.meta
+6
-0
Game.fire
play/assets/tmpGame/scene/Game.fire
+18
-18
game.js
play/assets/tmpGame/script/game/game.js
+260
-257
item.js
play/assets/tmpGame/script/game/item.js
+248
-248
No files found.
play/assets/resources/font/华文圆体 REGULAR.TTF
0 → 100644
View file @
93ad0fc2
File added
play/assets/resources/font/华文圆体 REGULAR.TTF.meta
0 → 100644
View file @
93ad0fc2
{
"ver": "1.1.0",
"uuid": "41ef287f-ba46-4313-a114-676b6eae4bca",
"subMetas": {}
}
\ No newline at end of file
play/assets/tmpGame/scene/Game.fire
View file @
93ad0fc2
...
...
@@ -189,7 +189,7 @@
"array": [
0,
0,
358.80515010544025
,
234.6928844255829
,
0,
0,
0,
...
...
@@ -804,7 +804,7 @@
"b": 77,
"a": 255
},
"_width":
3
,
"_width":
2
,
"_id": "7frrmdk2NGMbzvXCwfUI+h"
},
{
...
...
@@ -2943,11 +2943,11 @@
"_dstBlendFactor": 771,
"_string": "telefe",
"_N$string": "telefe",
"_fontSize": 2
4
,
"_lineHeight": 3
0
,
"_fontSize": 2
8
,
"_lineHeight": 3
2
,
"_enableWrapText": false,
"_N$file": {
"__uuid__": "
f0214b38-1b2a-41ef-aa3e-1d6949fd3b12
"
"__uuid__": "
41ef287f-ba46-4313-a114-676b6eae4bca
"
},
"_isSystemFontUsed": false,
"_spacingX": 0,
...
...
@@ -3106,11 +3106,11 @@
"_dstBlendFactor": 771,
"_string": "telefe",
"_N$string": "telefe",
"_fontSize": 2
4
,
"_lineHeight": 3
0
,
"_fontSize": 2
8
,
"_lineHeight": 3
2
,
"_enableWrapText": false,
"_N$file": {
"__uuid__": "
f0214b38-1b2a-41ef-aa3e-1d6949fd3b12
"
"__uuid__": "
41ef287f-ba46-4313-a114-676b6eae4bca
"
},
"_isSystemFontUsed": false,
"_spacingX": 0,
...
...
@@ -3563,8 +3563,8 @@
},
"_contentSize": {
"__type__": "cc.Size",
"width":
9
0,
"height":
42.84
"width":
13
0,
"height":
50
},
"_anchorPoint": {
"__type__": "cc.Vec2",
...
...
@@ -3617,11 +3617,11 @@
"_dstBlendFactor": 771,
"_string": "telefe",
"_N$string": "telefe",
"_fontSize":
32
,
"_lineHeight":
36
,
"_fontSize":
40
,
"_lineHeight":
44
,
"_enableWrapText": false,
"_N$file": {
"__uuid__": "
f0214b38-1b2a-41ef-aa3e-1d6949fd3b12
"
"__uuid__": "
41ef287f-ba46-4313-a114-676b6eae4bca
"
},
"_isSystemFontUsed": false,
"_spacingX": 0,
...
...
@@ -3726,8 +3726,8 @@
},
"_contentSize": {
"__type__": "cc.Size",
"width":
9
0,
"height":
42.84
"width":
13
0,
"height":
50
},
"_anchorPoint": {
"__type__": "cc.Vec2",
...
...
@@ -3780,11 +3780,11 @@
"_dstBlendFactor": 771,
"_string": "telefe",
"_N$string": "telefe",
"_fontSize":
32
,
"_lineHeight":
36
,
"_fontSize":
40
,
"_lineHeight":
44
,
"_enableWrapText": false,
"_N$file": {
"__uuid__": "
f0214b38-1b2a-41ef-aa3e-1d6949fd3b12
"
"__uuid__": "
41ef287f-ba46-4313-a114-676b6eae4bca
"
},
"_isSystemFontUsed": false,
"_spacingX": 0,
...
...
play/assets/tmpGame/script/game/game.js
View file @
93ad0fc2
...
...
@@ -2,261 +2,264 @@
* 游戏主逻辑
*/
var
game
=
cc
.
Class
({
extends
:
cc
.
Component
,
properties
:
{
Item_0
:
{
default
:
[],
type
:
cc
.
Node
,
displayName
:
"
预制体
"
},
contentArr_2
:
{
default
:
[],
type
:
cc
.
Node
,
displayName
:
"
底下内容2
"
},
contentArr_1
:
{
default
:
[],
type
:
cc
.
Node
,
displayName
:
"
目标位置
"
},
lb_title
:
{
default
:
null
,
type
:
cc
.
Label
,
displayName
:
"
大标题
"
},
// btnList: {
// default: [],
// type: cc.Button,
// displayName: "上下页"
// },
mask_node
:
{
default
:
null
,
type
:
cc
.
Node
,
displayName
:
"
遮罩
"
}
},
ctor
:
function
()
{
game
.
inst
=
this
;
g
.
game
=
game
;
},
// 生命周期 onLoad
onLoad
()
{
//初始化游戏
this
.
initGame
();
if
(
window
.
addEventListener
)
{
window
.
addEventListener
(
'
resize
'
,
this
.
scaleEventCallBack
,
false
)
}
else
if
(
window
.
attachEvent
)
{
window
.
attachEvent
(
'
resize
'
,
this
.
scaleEventCallBack
,
false
)
}
},
//屏幕缩放
scaleEventCallBack
:
function
()
{
g
.
event_mgr
.
send
(
"
adjustUI
"
);
},
//初始化游戏
initGame
:
function
()
{
//获得数据
g
.
res_mgr
.
getFormData
();
},
setAABB
(
Id
)
{
var
node
=
this
.
contentArr_1
[
Id
]
let
svLeftBottomPoint
=
node
.
parent
.
convertToWorldSpaceAR
(
cc
.
v2
(
node
.
x
-
node
.
anchorX
*
node
.
width
/
2
,
node
.
y
-
node
.
anchorY
*
node
.
height
/
2
)
);
// 求出 ScrollView 可视区域在世界坐标系中的矩形(碰撞盒)
let
svBBoxRect
=
cc
.
rect
(
svLeftBottomPoint
.
x
-
60
,
svLeftBottomPoint
.
y
-
30
,
node
.
width
,
node
.
height
);
// console.log(Id + ":" + svLeftBottomPoint.x + "," + svLeftBottomPoint.y);
return
svBBoxRect
},
//检查当前缩放倍数
checkScale
:
function
(
num
)
{
var
scale
=
1
;
if
(
num
>
2
&&
num
<=
4
)
{
scale
=
0.74
}
if
(
num
>
4
)
{
scale
=
0.65
}
return
scale
;
},
//添加节点
addItem
:
function
()
{
let
itemArr
=
g
.
data_mgr
.
getSheepArr
();
this
.
idx
=
this
.
checkNodeParent
();
g
.
data_mgr
.
nowNum
=
itemArr
.
length
;
for
(
var
i
=
0
;
i
<
itemArr
.
length
;
i
++
)
{
let
newItem_0
=
cc
.
instantiate
(
this
.
Item_0
[
itemArr
.
length
>
14
?
0
:
1
]);
//let newItem_1 = cc.instantiate(this.Item_1);
//更新子项
var
com
=
newItem_0
.
getChildByName
(
"
item
"
).
getComponent
(
"
item
"
);
let
itemInfo
=
itemArr
[
i
];
com
.
updateUI
(
itemInfo
);
newItem_0
.
active
=
true
;
// newItem_1.active = true;
//设置类别
let
sheepInfo
=
g
.
data_mgr
.
getSheep
(
i
);
newItem_0
.
getChildByName
(
"
item
"
).
type
=
this
.
checkType
(
sheepInfo
.
sheepfoldId
);
// newItem_1.parent = newItem_0;
// 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
();
//
if
(
itemArr
.
length
<=
7
)
{
this
.
contentArr_2
[
1
].
active
=
true
;
var
idx
=
1
;
}
else
{
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
)
{
return
~~
i
+
1
;
}
}
return
-
1
;
},
//更新界面信息
UpdataUi
:
function
()
{
//设置大标题
this
.
lb_title
.
string
=
g
.
data_mgr
.
getTitle
();
//设置俩个标题
this
.
contentArr_1
[
0
].
getChildByName
(
"
title
"
).
getComponent
(
cc
.
Label
).
string
=
g
.
data_mgr
.
getSheepfold
(
0
).
word
;
//设置俩个标题
this
.
contentArr_1
[
1
].
getChildByName
(
"
title
"
).
getComponent
(
cc
.
Label
).
string
=
g
.
data_mgr
.
getSheepfold
(
1
).
word
;
//重置UI界面
this
.
resetUI
();
//添加项
this
.
addItem
();
// //设置上下页按钮状态
// this.setButtonState();
},
//重置UI界面
resetUI
:
function
()
{
//移除所有子节点
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
();
//初始化界面
this
.
UpdataUi
();
g
.
speaker
.
inst
.
play_restart
();
},
//游戏开始
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
;
this
.
btnList
[
1
].
node
.
active
=
false
;
}
else
{
//如果第一页
if
(
g
.
data_mgr
.
pageId
==
0
)
{
this
.
btnList
[
1
].
node
.
active
=
true
;
this
.
btnList
[
0
].
node
.
active
=
false
;
}
if
(
g
.
data_mgr
.
pageId
==
g
.
data_mgr
.
data
.
contentObj
.
pageArr
.
length
-
1
)
{
this
.
btnList
[
0
].
node
.
active
=
true
;
this
.
btnList
[
1
].
node
.
active
=
false
;
}
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
)
{
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
)
{
g
.
data_mgr
.
pageId
+=
1
;
this
.
setButtonState
();
this
.
onBtnReStart
();
}
},
onBtnMask
:
function
()
{
if
(
this
.
isLoadEnd
)
{
this
.
isLoadEnd
=
false
;
g
.
speaker
.
inst
.
play_start
(()
=>
{
setTimeout
(()
=>
{
g
.
game
.
inst
.
playAudioTitle
(()
=>
{
g
.
game
.
inst
.
mask_node
.
active
=
false
;
//游戏开始
g
.
game
.
inst
.
gameStart
();
});
},
500
)
});
}
},
extends
:
cc
.
Component
,
properties
:
{
Item_0
:
{
default
:
[],
type
:
cc
.
Node
,
displayName
:
"
预制体
"
},
contentArr_2
:
{
default
:
[],
type
:
cc
.
Node
,
displayName
:
"
底下内容2
"
},
contentArr_1
:
{
default
:
[],
type
:
cc
.
Node
,
displayName
:
"
目标位置
"
},
lb_title
:
{
default
:
null
,
type
:
cc
.
Label
,
displayName
:
"
大标题
"
},
// btnList: {
// default: [],
// type: cc.Button,
// displayName: "上下页"
// },
mask_node
:
{
default
:
null
,
type
:
cc
.
Node
,
displayName
:
"
遮罩
"
}
},
ctor
:
function
()
{
game
.
inst
=
this
;
g
.
game
=
game
;
},
// 生命周期 onLoad
onLoad
()
{
//初始化游戏
this
.
initGame
();
if
(
window
.
addEventListener
)
{
window
.
addEventListener
(
'
resize
'
,
this
.
scaleEventCallBack
,
false
)
}
else
if
(
window
.
attachEvent
)
{
window
.
attachEvent
(
'
resize
'
,
this
.
scaleEventCallBack
,
false
)
}
},
//屏幕缩放
scaleEventCallBack
:
function
()
{
g
.
event_mgr
.
send
(
"
adjustUI
"
);
},
//初始化游戏
initGame
:
function
()
{
//获得数据
g
.
res_mgr
.
getFormData
();
},
setAABB
(
Id
)
{
var
node
=
this
.
contentArr_1
[
Id
]
let
svLeftBottomPoint
=
node
.
parent
.
convertToWorldSpaceAR
(
cc
.
v2
(
node
.
x
-
node
.
anchorX
*
node
.
width
/
2
,
node
.
y
-
node
.
anchorY
*
node
.
height
/
2
)
);
// 求出 ScrollView 可视区域在世界坐标系中的矩形(碰撞盒)
let
svBBoxRect
=
cc
.
rect
(
svLeftBottomPoint
.
x
-
120
,
svLeftBottomPoint
.
y
-
100
,
node
.
width
,
node
.
height
);
// console.log(Id + ":" + svLeftBottomPoint.x + "," + svLeftBottomPoint.y);
return
svBBoxRect
},
//检查当前缩放倍数
checkScale
:
function
(
num
)
{
var
scale
=
1
;
if
(
num
>
2
&&
num
<=
4
)
{
scale
=
0.74
}
if
(
num
>
4
)
{
scale
=
0.65
}
return
scale
;
},
//添加节点
addItem
:
function
()
{
let
itemArr
=
g
.
data_mgr
.
getSheepArr
();
this
.
idx
=
this
.
checkNodeParent
();
g
.
data_mgr
.
nowNum
=
itemArr
.
length
;
itemArr
.
sort
(
function
()
{
return
Math
.
random
()
>
0.5
?
-
1
:
1
;
})
for
(
var
i
=
0
;
i
<
itemArr
.
length
;
i
++
)
{
let
newItem_0
=
cc
.
instantiate
(
this
.
Item_0
[
itemArr
.
length
>
14
?
0
:
1
]);
//let newItem_1 = cc.instantiate(this.Item_1);
//更新子项
var
com
=
newItem_0
.
getChildByName
(
"
item
"
).
getComponent
(
"
item
"
);
let
itemInfo
=
itemArr
[
i
];
com
.
updateUI
(
itemInfo
);
newItem_0
.
active
=
true
;
// newItem_1.active = true;
//设置类别
let
sheepInfo
=
g
.
data_mgr
.
getSheep
(
i
);
newItem_0
.
getChildByName
(
"
item
"
).
type
=
this
.
checkType
(
sheepInfo
.
sheepfoldId
);
// newItem_1.parent = newItem_0;
// 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
();
//
if
(
itemArr
.
length
<=
7
)
{
this
.
contentArr_2
[
1
].
active
=
true
;
var
idx
=
1
;
}
else
{
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
)
{
return
~~
i
+
1
;
}
}
return
-
1
;
},
//更新界面信息
UpdataUi
:
function
()
{
//设置大标题
this
.
lb_title
.
string
=
g
.
data_mgr
.
getTitle
();
//设置俩个标题
this
.
contentArr_1
[
0
].
getChildByName
(
"
title
"
).
getComponent
(
cc
.
Label
).
string
=
g
.
data_mgr
.
getSheepfold
(
0
).
word
;
//设置俩个标题
this
.
contentArr_1
[
1
].
getChildByName
(
"
title
"
).
getComponent
(
cc
.
Label
).
string
=
g
.
data_mgr
.
getSheepfold
(
1
).
word
;
//重置UI界面
this
.
resetUI
();
//添加项
this
.
addItem
();
// //设置上下页按钮状态
// this.setButtonState();
},
//重置UI界面
resetUI
:
function
()
{
//移除所有子节点
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
();
//初始化界面
this
.
UpdataUi
();
g
.
speaker
.
inst
.
play_restart
();
},
//游戏开始
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
;
this
.
btnList
[
1
].
node
.
active
=
false
;
}
else
{
//如果第一页
if
(
g
.
data_mgr
.
pageId
==
0
)
{
this
.
btnList
[
1
].
node
.
active
=
true
;
this
.
btnList
[
0
].
node
.
active
=
false
;
}
if
(
g
.
data_mgr
.
pageId
==
g
.
data_mgr
.
data
.
contentObj
.
pageArr
.
length
-
1
)
{
this
.
btnList
[
0
].
node
.
active
=
true
;
this
.
btnList
[
1
].
node
.
active
=
false
;
}
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
)
{
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
)
{
g
.
data_mgr
.
pageId
+=
1
;
this
.
setButtonState
();
this
.
onBtnReStart
();
}
},
onBtnMask
:
function
()
{
if
(
this
.
isLoadEnd
)
{
this
.
isLoadEnd
=
false
;
g
.
speaker
.
inst
.
play_start
(()
=>
{
setTimeout
(()
=>
{
g
.
game
.
inst
.
playAudioTitle
(()
=>
{
g
.
game
.
inst
.
mask_node
.
active
=
false
;
//游戏开始
g
.
game
.
inst
.
gameStart
();
});
},
500
)
});
}
},
});
play/assets/tmpGame/script/game/item.js
View file @
93ad0fc2
...
...
@@ -3,252 +3,252 @@
*/
cc
.
Class
({
extends
:
cc
.
Component
,
properties
:
{
Item_name
:
{
default
:
null
,
type
:
cc
.
Label
,
displayName
:
"
名字
"
},
Item_redName
:
{
default
:
null
,
type
:
cc
.
Label
,
displayName
:
"
红色名字
"
},
Item_photo
:
{
default
:
null
,
type
:
cc
.
Node
,
displayName
:
"
图片
"
},
Item_complete
:
{
default
:
null
,
type
:
cc
.
Node
,
displayName
:
"
完成显示
"
},
},
start
:
function
()
{
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_END
,
this
.
touchEnd
,
this
);
this
.
node
.
on
(
cc
.
Node
.
EventType
.
TOUCH_CANCEL
,
this
.
touchCancel
,
this
);
},
//触摸开始
touchBegan
:
function
(
event
)
{
this
.
isMove
=
false
;
this
.
deltaPos
=
this
.
node
.
x
+
this
.
node
.
y
;
},
//触摸移动
touchMove
:
function
(
event
)
{
if
(
this
.
node
.
isComplent
)
{
return
}
// var posScreen = event.getLocation(); //点击事件获取位置
// var posNode = this.node.parent.convertToNodeSpaceAR(posScreen);
// var iposTouch = this.getFormatIPos(posNode);
var
delta
=
event
.
getDelta
();
this
.
node
.
x
+=
delta
.
x
;
this
.
node
.
y
+=
delta
.
y
;
var
deltaPos
=
this
.
node
.
x
+
this
.
node
.
y
;
if
(
Math
.
abs
(
this
.
deltaPos
-
deltaPos
)
>
10
)
{
this
.
isMove
=
true
;
}
},
//触摸结束
touchEnd
:
function
(
event
)
{
//获得世界坐标
var
posScreen
=
event
.
getLocation
();
//点击事件获取位置
var
posNode
=
this
.
node
.
convertToNodeSpaceAR
(
posScreen
);
console
.
log
(
"
世界坐标
"
+
posNode
);
if
(
!
this
.
isMove
)
{
cc
.
log
(
"
点击了
"
);
this
.
onBtnRotate
();
//回到原来的位置
this
.
node
.
x
=
0
;
this
.
node
.
y
=
0
;
return
}
//获得俩个节点的世界坐标
var
contentArrPos_0
=
g
.
game
.
inst
.
setAABB
(
0
);
var
contentArrPos_1
=
g
.
game
.
inst
.
setAABB
(
1
);
// 获取 ScrollView Node 的左下角坐标在世界坐标系中的坐标
let
svLeftBottomPoint
=
this
.
node
.
parent
.
convertToWorldSpaceAR
(
cc
.
v2
(
this
.
node
.
x
-
this
.
node
.
anchorX
*
this
.
node
.
width
,
this
.
node
.
y
-
this
.
node
.
anchorY
*
this
.
node
.
height
)
);
// 求出 ScrollView 可视区域在世界坐标系中的矩形(碰撞盒)
var
posNode_1
=
cc
.
rect
(
svLeftBottomPoint
.
x
,
svLeftBottomPoint
.
y
,
this
.
node
.
width
,
this
.
node
.
height
);
var
isIntersect_1
=
contentArrPos_1
.
containsRect
(
posNode_1
);
//判断是否被包含
var
isIntersect_0
=
contentArrPos_0
.
containsRect
(
posNode_1
);
// console.log("坐标" + svLeftBottomPoint.x + "," + svLeftBottomPoint.y + "是否包含" + isIntersect_1);
if
(
isIntersect_1
)
{
if
(
this
.
node
.
type
==
1
)
{
this
.
Item_complete
.
active
=
true
;
this
.
node
.
isComplent
=
true
;
g
.
data_mgr
.
nowNum
-=
1
;
if
(
g
.
data_mgr
.
nowNum
==
0
)
{
g
.
effect
.
inst
.
showEffect2
();
}
g
.
speaker
.
inst
.
play_good
();
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
"
).
getComponent
(
dragonBones
.
ArmatureDisplay
).
playAnimation
(
"
newAnimation
"
,
1
);
if
(
g
.
game
.
inst
.
idx
==
1
)
{
this
.
node
.
scale
=
0.666
;
this
.
node
.
x
=
0
;
}
this
.
node
.
parent
=
newItem_temp
;
newItem_temp
.
parent
=
g
.
game
.
inst
.
contentArr_1
[
1
].
getChildByName
(
"
connent_3
"
).
getChildByName
(
"
Layout
"
);
this
.
node
.
x
=
0
;
this
.
node
.
y
=
0
;
}
else
{
this
.
errorEffect
();
}
console
.
log
(
"
被1包含
"
+
isIntersect_1
);
}
else
if
(
isIntersect_0
)
{
if
(
this
.
node
.
type
==
2
)
{
this
.
Item_complete
.
active
=
true
;
this
.
node
.
isComplent
=
true
;
g
.
data_mgr
.
nowNum
-=
1
;
if
(
g
.
data_mgr
.
nowNum
==
0
)
{
g
.
effect
.
inst
.
showEffect2
();
}
g
.
speaker
.
inst
.
play_good
();
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
"
).
getComponent
(
dragonBones
.
ArmatureDisplay
).
playAnimation
(
"
newAnimation
"
,
1
);
if
(
g
.
game
.
inst
.
idx
==
1
)
{
this
.
node
.
scale
=
0.666
;
this
.
node
.
x
=
0
;
}
this
.
node
.
parent
=
newItem_temp
;
newItem_temp
.
parent
=
g
.
game
.
inst
.
contentArr_1
[
0
].
getChildByName
(
"
connent_3
"
).
getChildByName
(
"
Layout
"
);
this
.
node
.
x
=
0
;
this
.
node
.
y
=
0
;
console
.
log
(
"
被2包含
"
+
isIntersect_0
);
}
else
{
this
.
errorEffect
();
}
}
else
{
//回到原来的位置
this
.
node
.
x
=
0
;
this
.
node
.
y
=
0
;
}
},
errorEffect
:
function
()
{
g
.
speaker
.
inst
.
play_error
();
this
.
node
.
getChildByName
(
"
red
"
).
active
=
true
;
cc
.
tween
(
this
.
node
)
.
to
(
0.1
,
{
scaleY
:
0.9
,
scaleX
:
1.1
})
.
to
(
0.15
,
{
scaleY
:
1.1
,
scaleX
:
0.9
})
.
to
(
0.1
,
{
scaleY
:
1
,
scaleX
:
1
})
.
start
()
setTimeout
(()
=>
{
this
.
node
.
getChildByName
(
"
red
"
).
active
=
false
;
//回到原来的位置
this
.
node
.
x
=
0
;
this
.
node
.
y
=
0
;
},
500
)
},
//触摸取消
touchCancel
:
function
(
event
)
{
//回到原来的位置
this
.
node
.
x
=
0
;
this
.
node
.
y
=
0
;
this
.
isMove
=
false
;
},
//更新界面ui
updateUI
:
function
(
Info
)
{
//当前数据
this
.
itemInfo
=
Info
;
//初始化数据
this
.
InitData
();
//是否已经完成了
this
.
node
.
isComplent
=
false
;
},
//点击翻面
onBtnRotate
:
function
()
{
//翻面音效
g
.
speaker
.
inst
.
play_btn
();
var
scaleX
=
this
.
node
.
scaleY
;
cc
.
tween
(
this
.
node
)
.
to
(
0.3
,
{
scaleX
:
0
})
.
call
(()
=>
{
if
(
this
.
Item_name
.
node
.
active
)
{
this
.
Item_name
.
node
.
active
=
false
;
this
.
Item_photo
.
active
=
true
;
this
.
Item_redNam
e
.
active
=
false
;
}
else
{
this
.
Item_name
.
node
.
active
=
true
;
this
.
Item_photo
.
active
=
false
;
this
.
Item_redNam
e
.
active
=
true
;
}
})
.
to
(
0.3
,
{
scaleX
:
scaleX
})
.
start
();
},
//初始化信息
InitData
:
function
()
{
//设置图片
g
.
res_mgr
.
getSpriteFrimeByUrl
(
this
.
itemInfo
.
picUrl
,
(
list
)
=>
{
this
.
Item_photo
.
getComponent
(
cc
.
Sprite
).
spriteFrame
=
list
;
this
.
photoScare
(
this
.
Item_photo
,
g
.
game
.
inst
.
idx
);
// this.photoScare(this.nodeState[2].getChildByName("spt_item"), 1);
});
//设置名字
this
.
Item_name
.
string
=
this
.
itemInfo
.
word
;
//设置红色名字
this
.
Item_redName
.
string
=
this
.
itemInfo
.
word
;
},
//图片适配
photoScare
:
function
(
node
,
type
)
{
var
maxNum
=
type
==
0
?
50
:
75
;
let
maxSize
=
Math
.
min
(
maxNum
/
node
.
height
,
maxNum
/
node
.
width
);
if
(
node
.
perScale
==
undefined
)
{
node
.
perScale
=
node
.
scaleX
;
}
else
{
node
.
scaleX
=
node
.
perScale
;
node
.
scaleY
=
node
.
perScale
;
}
node
.
scaleX
*=
maxSize
;
node
.
scaleY
*=
maxSize
;
},
extends
:
cc
.
Component
,
properties
:
{
Item_name
:
{
default
:
null
,
type
:
cc
.
Label
,
displayName
:
"
名字
"
},
Item_redName
:
{
default
:
null
,
type
:
cc
.
Label
,
displayName
:
"
红色名字
"
},
Item_photo
:
{
default
:
null
,
type
:
cc
.
Node
,
displayName
:
"
图片
"
},
Item_complete
:
{
default
:
null
,
type
:
cc
.
Node
,
displayName
:
"
完成显示
"
},
},
start
:
function
()
{
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_END
,
this
.
touchEnd
,
this
);
this
.
node
.
on
(
cc
.
Node
.
EventType
.
TOUCH_CANCEL
,
this
.
touchCancel
,
this
);
},
//触摸开始
touchBegan
:
function
(
event
)
{
this
.
isMove
=
false
;
this
.
deltaPos
=
this
.
node
.
x
+
this
.
node
.
y
;
},
//触摸移动
touchMove
:
function
(
event
)
{
if
(
this
.
node
.
isComplent
)
{
return
}
// var posScreen = event.getLocation(); //点击事件获取位置
// var posNode = this.node.parent.convertToNodeSpaceAR(posScreen);
// var iposTouch = this.getFormatIPos(posNode);
var
delta
=
event
.
getDelta
();
this
.
node
.
x
+=
delta
.
x
;
this
.
node
.
y
+=
delta
.
y
;
var
deltaPos
=
this
.
node
.
x
+
this
.
node
.
y
;
if
(
Math
.
abs
(
this
.
deltaPos
-
deltaPos
)
>
10
)
{
this
.
isMove
=
true
;
}
},
//触摸结束
touchEnd
:
function
(
event
)
{
//获得世界坐标
var
posScreen
=
event
.
getLocation
();
//点击事件获取位置
var
posNode
=
this
.
node
.
convertToNodeSpaceAR
(
posScreen
);
console
.
log
(
"
世界坐标
"
+
posNode
);
if
(
!
this
.
isMove
)
{
cc
.
log
(
"
点击了
"
);
this
.
onBtnRotate
();
//回到原来的位置
this
.
node
.
x
=
0
;
this
.
node
.
y
=
0
;
return
}
//获得俩个节点的世界坐标
var
contentArrPos_0
=
g
.
game
.
inst
.
setAABB
(
0
);
var
contentArrPos_1
=
g
.
game
.
inst
.
setAABB
(
1
);
// 获取 ScrollView Node 的左下角坐标在世界坐标系中的坐标
let
svLeftBottomPoint
=
this
.
node
.
parent
.
convertToWorldSpaceAR
(
cc
.
v2
(
this
.
node
.
x
-
this
.
node
.
anchorX
*
this
.
node
.
width
,
this
.
node
.
y
-
this
.
node
.
anchorY
*
this
.
node
.
height
)
);
// 求出 ScrollView 可视区域在世界坐标系中的矩形(碰撞盒)
var
posNode_1
=
cc
.
rect
(
svLeftBottomPoint
.
x
,
svLeftBottomPoint
.
y
,
this
.
node
.
width
,
this
.
node
.
height
);
var
isIntersect_1
=
contentArrPos_1
.
containsRect
(
posNode_1
);
//判断是否被包含
var
isIntersect_0
=
contentArrPos_0
.
containsRect
(
posNode_1
);
// console.log("坐标" + svLeftBottomPoint.x + "," + svLeftBottomPoint.y + "是否包含" + isIntersect_1);
if
(
isIntersect_1
)
{
if
(
this
.
node
.
type
==
1
)
{
this
.
Item_complete
.
active
=
true
;
this
.
node
.
isComplent
=
true
;
g
.
data_mgr
.
nowNum
-=
1
;
if
(
g
.
data_mgr
.
nowNum
==
0
)
{
g
.
effect
.
inst
.
showEffect2
();
}
g
.
speaker
.
inst
.
play_good
();
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
"
).
getComponent
(
dragonBones
.
ArmatureDisplay
).
playAnimation
(
"
newAnimation
"
,
1
);
if
(
g
.
game
.
inst
.
idx
==
1
)
{
this
.
node
.
scale
=
0.666
;
this
.
node
.
x
=
0
;
}
this
.
node
.
parent
=
newItem_temp
;
newItem_temp
.
parent
=
g
.
game
.
inst
.
contentArr_1
[
1
].
getChildByName
(
"
connent_3
"
).
getChildByName
(
"
Layout
"
);
this
.
node
.
x
=
0
;
this
.
node
.
y
=
0
;
}
else
{
this
.
errorEffect
();
}
console
.
log
(
"
被1包含
"
+
isIntersect_1
);
}
else
if
(
isIntersect_0
)
{
if
(
this
.
node
.
type
==
2
)
{
this
.
Item_complete
.
active
=
true
;
this
.
node
.
isComplent
=
true
;
g
.
data_mgr
.
nowNum
-=
1
;
if
(
g
.
data_mgr
.
nowNum
==
0
)
{
g
.
effect
.
inst
.
showEffect2
();
}
g
.
speaker
.
inst
.
play_good
();
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
"
).
getComponent
(
dragonBones
.
ArmatureDisplay
).
playAnimation
(
"
newAnimation
"
,
1
);
if
(
g
.
game
.
inst
.
idx
==
1
)
{
this
.
node
.
scale
=
0.666
;
this
.
node
.
x
=
0
;
}
this
.
node
.
parent
=
newItem_temp
;
newItem_temp
.
parent
=
g
.
game
.
inst
.
contentArr_1
[
0
].
getChildByName
(
"
connent_3
"
).
getChildByName
(
"
Layout
"
);
this
.
node
.
x
=
0
;
this
.
node
.
y
=
0
;
console
.
log
(
"
被2包含
"
+
isIntersect_0
);
}
else
{
this
.
errorEffect
();
}
}
else
{
//回到原来的位置
this
.
node
.
x
=
0
;
this
.
node
.
y
=
0
;
}
},
errorEffect
:
function
()
{
g
.
speaker
.
inst
.
play_error
();
this
.
node
.
getChildByName
(
"
red
"
).
active
=
true
;
cc
.
tween
(
this
.
node
)
.
to
(
0.1
,
{
scaleY
:
0.9
,
scaleX
:
1.1
})
.
to
(
0.15
,
{
scaleY
:
1.1
,
scaleX
:
0.9
})
.
to
(
0.1
,
{
scaleY
:
1
,
scaleX
:
1
})
.
start
()
setTimeout
(()
=>
{
this
.
node
.
getChildByName
(
"
red
"
).
active
=
false
;
//回到原来的位置
this
.
node
.
x
=
0
;
this
.
node
.
y
=
0
;
},
500
)
},
//触摸取消
touchCancel
:
function
(
event
)
{
//回到原来的位置
this
.
node
.
x
=
0
;
this
.
node
.
y
=
0
;
this
.
isMove
=
false
;
},
//更新界面ui
updateUI
:
function
(
Info
)
{
//当前数据
this
.
itemInfo
=
Info
;
//初始化数据
this
.
InitData
();
//是否已经完成了
this
.
node
.
isComplent
=
false
;
},
//点击翻面
onBtnRotate
:
function
()
{
//翻面音效
g
.
speaker
.
inst
.
play_btn
();
var
scaleX
=
this
.
node
.
scaleY
;
cc
.
tween
(
this
.
node
)
.
to
(
0.3
,
{
scaleX
:
0
})
.
call
(()
=>
{
if
(
this
.
Item_name
.
node
.
active
)
{
this
.
Item_name
.
node
.
active
=
false
;
this
.
Item_photo
.
active
=
true
;
this
.
Item_redName
.
nod
e
.
active
=
false
;
}
else
{
this
.
Item_name
.
node
.
active
=
true
;
this
.
Item_photo
.
active
=
false
;
this
.
Item_redName
.
nod
e
.
active
=
true
;
}
})
.
to
(
0.3
,
{
scaleX
:
scaleX
})
.
start
();
},
//初始化信息
InitData
:
function
()
{
//设置图片
g
.
res_mgr
.
getSpriteFrimeByUrl
(
this
.
itemInfo
.
picUrl
,
(
list
)
=>
{
this
.
Item_photo
.
getComponent
(
cc
.
Sprite
).
spriteFrame
=
list
;
this
.
photoScare
(
this
.
Item_photo
,
g
.
game
.
inst
.
idx
);
// this.photoScare(this.nodeState[2].getChildByName("spt_item"), 1);
});
//设置名字
this
.
Item_name
.
string
=
this
.
itemInfo
.
word
;
//设置红色名字
this
.
Item_redName
.
string
=
this
.
itemInfo
.
word
;
},
//图片适配
photoScare
:
function
(
node
,
type
)
{
var
maxNum
=
type
==
0
?
50
:
75
;
let
maxSize
=
Math
.
min
(
maxNum
/
node
.
height
,
maxNum
/
node
.
width
);
if
(
node
.
perScale
==
undefined
)
{
node
.
perScale
=
node
.
scaleX
;
}
else
{
node
.
scaleX
=
node
.
perScale
;
node
.
scaleY
=
node
.
perScale
;
}
node
.
scaleX
*=
maxSize
;
node
.
scaleY
*=
maxSize
;
},
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment