Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
comparetree
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
comparetree
Commits
04f41b74
Commit
04f41b74
authored
Jun 12, 2021
by
Tt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
4d9f0709
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
80 additions
and
33 deletions
+80
-33
scene.fire
play/assets/scene/scene/scene.fire
+2
-2
scene.js
play/assets/scene/scene/scene.js
+78
-31
No files found.
play/assets/scene/scene/scene.fire
View file @
04f41b74
...
@@ -4579,7 +4579,7 @@
...
@@ -4579,7 +4579,7 @@
"__id__": 91
"__id__": 91
},
},
"_children": [],
"_children": [],
"_active":
fals
e,
"_active":
tru
e,
"_components": [
"_components": [
{
{
"__id__": 93
"__id__": 93
...
@@ -4676,7 +4676,7 @@
...
@@ -4676,7 +4676,7 @@
"__id__": 91
"__id__": 91
},
},
"_children": [],
"_children": [],
"_active":
fals
e,
"_active":
tru
e,
"_components": [
"_components": [
{
{
"__id__": 95
"__id__": 95
...
...
play/assets/scene/scene/scene.js
View file @
04f41b74
...
@@ -278,12 +278,9 @@ cc.Class({
...
@@ -278,12 +278,9 @@ cc.Class({
let
posY
=
y
+
addY
*
Math
.
floor
(
i
/
7
);
let
posY
=
y
+
addY
*
Math
.
floor
(
i
/
7
);
sonClone
.
x
=
posX
;
sonClone
.
x
=
posX
;
sonClone
.
y
=
posY
;
sonClone
.
y
=
posY
;
sonClone
.
cardState
=
0
;
this
.
initButton
(
sonClone
);
this
.
initButton
(
sonClone
);
let
icon
=
sonClone
.
getChildByName
(
"
icon
"
);
this
.
updateItem
(
sonClone
);
let
txt
=
sonClone
.
getChildByName
(
"
txt
"
);
icon
.
active
=
false
;
txt
.
active
=
true
;
pg
.
view
.
setString
(
txt
,
data
.
txt
);
box
.
addChild
(
sonClone
);
box
.
addChild
(
sonClone
);
}
}
}
else
{
}
else
{
...
@@ -304,17 +301,71 @@ cc.Class({
...
@@ -304,17 +301,71 @@ cc.Class({
sonClone
.
y
=
posY
;
sonClone
.
y
=
posY
;
sonClone
.
scaleX
=
scale
;
sonClone
.
scaleX
=
scale
;
sonClone
.
scaleY
=
scale
;
sonClone
.
scaleY
=
scale
;
sonClone
.
cardState
=
0
;
this
.
initButton
(
sonClone
);
this
.
initButton
(
sonClone
);
let
icon
=
sonClone
.
getChildByName
(
"
icon
"
);
this
.
updateItem
(
sonClone
);
let
txt
=
sonClone
.
getChildByName
(
"
txt
"
);
icon
.
active
=
false
;
txt
.
active
=
true
;
pg
.
view
.
setString
(
txt
,
data
.
txt
);
box
.
addChild
(
sonClone
);
box
.
addChild
(
sonClone
);
}
}
}
}
},
},
updateItem
(
item
)
{
let
data
=
item
.
data
;
let
bg
=
item
.
getChildByName
(
"
bg
"
);
let
icon
=
item
.
getChildByName
(
"
icon
"
);
let
txt
=
item
.
getChildByName
(
"
txt
"
);
let
chose
=
item
.
getChildByName
(
"
chose
"
);
let
fail
=
item
.
getChildByName
(
"
fail
"
);
let
success
=
item
.
getChildByName
(
"
success
"
);
if
(
item
.
cardState
==
0
)
{
//文字
icon
.
active
=
false
;
txt
.
active
=
true
;
pg
.
view
.
visible
(
pg
.
view
.
find
(
success
,
"
icon
"
),
false
);
pg
.
view
.
visible
(
pg
.
view
.
find
(
success
,
"
txt
"
),
true
);
}
else
if
(
item
.
cardState
==
1
)
{
//图片
icon
.
active
=
true
;
txt
.
active
=
false
;
pg
.
view
.
visible
(
pg
.
view
.
find
(
success
,
"
icon
"
),
true
);
pg
.
view
.
visible
(
pg
.
view
.
find
(
success
,
"
txt
"
),
false
);
}
pg
.
view
.
setString
(
txt
,
data
.
txt
);
pg
.
view
.
setString
(
pg
.
view
.
find
(
success
,
"
txt
"
),
data
.
txt
);
switch
(
item
.
moveState
)
{
case
1
:
bg
.
active
=
true
;
chose
.
active
=
true
;
fail
.
active
=
false
;
success
.
active
=
false
;
break
;
case
2
:
bg
.
active
=
false
;
chose
.
active
=
false
;
fail
.
active
=
false
;
success
.
active
=
true
;
icon
.
active
=
false
;
txt
.
active
=
false
;
break
;
case
3
:
bg
.
active
=
false
;
chose
.
active
=
false
;
fail
.
active
=
true
;
success
.
active
=
false
;
break
;
default
:
bg
.
active
=
true
;
chose
.
active
=
false
;
fail
.
active
=
false
;
success
.
active
=
false
;
break
;
}
},
moveItem
(
item
,
pos
)
{
item
.
x
=
pos
.
x
;
item
.
y
=
pos
.
y
;
},
initButton
(
item
)
{
initButton
(
item
)
{
item
.
on
(
cc
.
Node
.
EventType
.
TOUCH_START
,
this
.
onStartItem
,
this
);
item
.
on
(
cc
.
Node
.
EventType
.
TOUCH_START
,
this
.
onStartItem
,
this
);
item
.
on
(
cc
.
Node
.
EventType
.
TOUCH_END
,
this
.
onEndItem
,
this
);
item
.
on
(
cc
.
Node
.
EventType
.
TOUCH_END
,
this
.
onEndItem
,
this
);
...
@@ -330,6 +381,9 @@ cc.Class({
...
@@ -330,6 +381,9 @@ cc.Class({
// touch.target.x = touchPos.x - 1280 / 2;
// touch.target.x = touchPos.x - 1280 / 2;
// touch.target.y = touchPos.y - 720 / 2;
// touch.target.y = touchPos.y - 720 / 2;
},
},
//1.移动效果--在节点上绑定一个运动的type 根据type来刷新按钮效果 刷新type的方法,和具体的执行的时候刷新type
//2.成功效果--
//3.失败效果--
onEndItem
(
touch
)
{
onEndItem
(
touch
)
{
let
item
=
touch
.
target
;
let
item
=
touch
.
target
;
let
touchPos
=
touch
.
getLocation
();
let
touchPos
=
touch
.
getLocation
();
...
@@ -344,19 +398,11 @@ cc.Class({
...
@@ -344,19 +398,11 @@ cc.Class({
height
:
50
,
//item.height
height
:
50
,
//item.height
}))
{
}))
{
//回归原位
//回归原位
item
.
x
=
this
.
_startPos
.
x
;
this
.
moveItem
(
item
,
this
.
_startPos
);
item
.
y
=
this
.
_startPos
.
y
;
//变换动画
//变换动画
ani
.
flipX0
(
item
).
then
(()
=>
{
ani
.
flipX0
(
item
).
then
(()
=>
{
let
icon
=
item
.
getChildByName
(
"
icon
"
);
item
.
cardState
=
item
.
cardState
==
0
?
1
:
0
;
let
txt
=
item
.
getChildByName
(
"
txt
"
);
this
.
updateItem
(
item
);
if
(
txt
.
active
)
{
icon
.
active
=
true
;
txt
.
active
=
false
;
}
else
{
icon
.
active
=
false
;
txt
.
active
=
true
;
}
ani
.
flipX1
(
item
);
ani
.
flipX1
(
item
);
})
})
return
;
return
;
...
@@ -367,18 +413,19 @@ cc.Class({
...
@@ -367,18 +413,19 @@ 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
)
{
alert
(
"
成功
"
)
item
.
moveState
=
2
;
this
.
updateItem
(
item
);
}
else
{
}
else
{
alert
(
"
失败
"
)
item
.
moveState
=
3
;
//碰撞失败退回原位置
this
.
updateItem
(
item
);
item
.
x
=
this
.
_startPos
.
x
;
// //碰撞失败退回原位置
item
.
y
=
this
.
_startPos
.
y
;
setTimeout
(()
=>
{
this
.
moveItem
(
item
,
this
.
_startPos
);
},
100
);
}
}
}
else
{
}
else
{
//碰撞失败退回原位置
this
.
moveItem
(
item
,
this
.
_startPos
);
item
.
x
=
this
.
_startPos
.
x
;
item
.
y
=
this
.
_startPos
.
y
;
}
}
},
},
onMoveItem
(
touch
)
{
onMoveItem
(
touch
)
{
...
@@ -397,6 +444,8 @@ cc.Class({
...
@@ -397,6 +444,8 @@ cc.Class({
}))
{
}))
{
return
;
return
;
}
}
item
.
moveState
=
1
;
this
.
updateItem
(
item
);
touch
.
target
.
x
=
touchPos
.
x
-
1280
/
2
;
touch
.
target
.
x
=
touchPos
.
x
-
1280
/
2
;
touch
.
target
.
y
=
touchPos
.
y
-
720
/
2
;
touch
.
target
.
y
=
touchPos
.
y
-
720
/
2
;
},
},
...
@@ -474,8 +523,6 @@ cc.Class({
...
@@ -474,8 +523,6 @@ cc.Class({
...
...
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