Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
H
hy04_pinci
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
hy04_pinci
Commits
99131e78
Commit
99131e78
authored
Jun 16, 2023
by
Tt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
拖动部分完成
parent
411b0a56
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
38 deletions
+49
-38
hy01_danci.fire
assets/hy01_danci/scene/hy01_danci.fire
+2
-2
hy01_danci.ts
assets/hy01_danci/scene/hy01_danci.ts
+47
-36
No files found.
assets/hy01_danci/scene/hy01_danci.fire
View file @
99131e78
...
@@ -386,7 +386,7 @@
...
@@ -386,7 +386,7 @@
"__id__": 2
"__id__": 2
},
},
"_children": [],
"_children": [],
"_active":
tru
e,
"_active":
fals
e,
"_components": [
"_components": [
{
{
"__id__": 9
"__id__": 9
...
@@ -802,7 +802,7 @@
...
@@ -802,7 +802,7 @@
"node": {
"node": {
"__id__": 14
"__id__": 14
},
},
"_enabled":
tru
e,
"_enabled":
fals
e,
"_materials": [
"_materials": [
{
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
...
...
assets/hy01_danci/scene/hy01_danci.ts
View file @
99131e78
...
@@ -27,7 +27,6 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -27,7 +27,6 @@ export default class SceneComponent extends MyCocosSceneComponent {
this
.
initView
();
this
.
initView
();
this
.
initListener
();
this
.
initListener
();
this
.
initEvent
()
this
.
initEvent
()
this
.
initGame
();
}
}
// 一轮单词数量
// 一轮单词数量
private
static
Word_List_Len
:
number
=
8
;
private
static
Word_List_Len
:
number
=
8
;
...
@@ -208,7 +207,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -208,7 +207,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
getItemPosWidthByAns
(
ansArr
,
itemAnsArr
,
count
)
{
getItemPosWidthByAns
(
ansArr
,
itemAnsArr
,
count
)
{
//根据总长度计算出需要预留的空间大小
//根据总长度计算出需要预留的空间大小
let
defaultPos
=
cc
.
v2
(
0
,
-
27
0
);
let
defaultPos
=
cc
.
v2
(
0
,
-
30
0
);
let
singleWordWidth
=
220
;
let
singleWordWidth
=
220
;
let
orgPos
=
this
.
getTotalWordWidth
(
ansArr
,
singleWordWidth
,
defaultPos
);
let
orgPos
=
this
.
getTotalWordWidth
(
ansArr
,
singleWordWidth
,
defaultPos
);
let
itemWidth
=
itemAnsArr
.
length
*
singleWordWidth
;
let
itemWidth
=
itemAnsArr
.
length
*
singleWordWidth
;
...
@@ -223,7 +222,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -223,7 +222,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
}
getWordPosByAns
(
ansArr
,
data
)
{
getWordPosByAns
(
ansArr
,
data
)
{
//根据总长度计算出需要预留的空间大小
//根据总长度计算出需要预留的空间大小
let
defaultPos
=
cc
.
v2
(
0
,
-
27
0
);
let
defaultPos
=
cc
.
v2
(
0
,
-
30
0
);
let
singleWordWidth
=
220
;
let
singleWordWidth
=
220
;
let
orgPos
=
this
.
getTotalWordWidth
(
ansArr
,
singleWordWidth
,
defaultPos
);
let
orgPos
=
this
.
getTotalWordWidth
(
ansArr
,
singleWordWidth
,
defaultPos
);
// 计算当前是第几个
// 计算当前是第几个
...
@@ -273,6 +272,11 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -273,6 +272,11 @@ export default class SceneComponent extends MyCocosSceneComponent {
child
.
y
=
0
;
child
.
y
=
0
;
return
child
;
return
child
;
}
}
getWordBgByGroup
(
group
)
{
return
this
.
wordBgList
.
filter
(
item
=>
{
return
item
.
data
.
group
==
group
})
}
collider
(
node
)
{
collider
(
node
)
{
// 每个字母
// 每个字母
let
worldPos
=
cc
.
v2
(
node
.
x
,
node
.
y
);
let
worldPos
=
cc
.
v2
(
node
.
x
,
node
.
y
);
...
@@ -303,8 +307,13 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -303,8 +307,13 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
}
return
groupId
;
return
groupId
;
}
}
private
currentItem
:
cc
.
Node
;
onTouchStart
(
event
)
{
onTouchStart
(
event
)
{
console
.
log
(
'
1
'
)
console
.
log
(
'
1
'
)
let
node
=
event
.
target
;
this
.
currentItem
=
node
;
this
.
startCurrentItemAni
();
}
}
onTouchMove
(
event
)
{
onTouchMove
(
event
)
{
let
node
=
event
.
target
;
let
node
=
event
.
target
;
...
@@ -320,10 +329,25 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -320,10 +329,25 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
}
onTouchEnd
(
event
)
{
onTouchEnd
(
event
)
{
let
node
=
event
.
target
;
let
node
=
event
.
target
;
this
.
stopCurrentItemAni
();
this
.
currentItem
=
null
;
// 跟字母区域进行碰撞检测
// 跟字母区域进行碰撞检测
let
groupId
=
this
.
collider
(
node
);
let
groupId
=
this
.
collider
(
node
);
// 获取当前待碰撞区域
// 获取当前待碰撞区域
if
(
!
groupId
&&
groupId
!=
0
)
{
if
((
groupId
||
groupId
==
0
)
&&
node
.
data
[
0
].
data
.
group
==
groupId
)
{
console
.
log
(
groupId
)
// 正确了 需要处理效果
let
nodes
=
node
.
data
;
let
targets
=
this
.
getWordBgByGroup
(
groupId
);
nodes
.
forEach
(
item
=>
{
let
dt
=
item
.
data
;
let
target
=
targets
.
find
(
tr
=>
tr
.
data
.
index
==
item
.
data
.
index
);
this
.
wordToWordBg
(
item
,
target
);
})
node
.
off
(
cc
.
Node
.
EventType
.
TOUCH_START
,
this
.
onTouchStart
,
this
);
node
.
off
(
cc
.
Node
.
EventType
.
TOUCH_MOVE
,
this
.
onTouchMove
,
this
);
node
.
off
(
cc
.
Node
.
EventType
.
TOUCH_END
,
this
.
onTouchEnd
,
this
);
}
else
{
let
subX
=
node
.
x
-
node
.
orgPos
.
x
;
let
subX
=
node
.
x
-
node
.
orgPos
.
x
;
let
subY
=
node
.
y
-
node
.
orgPos
.
y
;
let
subY
=
node
.
y
-
node
.
orgPos
.
y
;
node
.
x
-=
subX
;
node
.
x
-=
subX
;
...
@@ -332,46 +356,33 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -332,46 +356,33 @@ export default class SceneComponent extends MyCocosSceneComponent {
nd
.
x
-=
subX
;
nd
.
x
-=
subX
;
nd
.
y
-=
subY
;
nd
.
y
-=
subY
;
})
})
}
else
{
// let data = colliderNode.data;
// console.log(JSON.stringify(data));
console
.
log
(
groupId
)
// nd运动到对应的节点
// let list = []
// node.children.forEach(nd => {
// nd.parent = node.parent;
// })
// // let target = this.getBgNodeByGroupIndex(nd.data.group, nd.data.index);
// // let pos = node.convertToNodeSpaceAR(target.convertToWorldSpaceAR(cc.v2(0, 0)));
// // cc.tween(nd).to(0.3, { x: pos.x, y: pos.y, scale: 0.8 }).start();
// node.off(cc.Node.EventType.TOUCH_START, this.onTouchStart, this);
// node.off(cc.Node.EventType.TOUCH_MOVE, this.onTouchMove, this);
// node.off(cc.Node.EventType.TOUCH_END, this.onTouchEnd, this);
}
}
}
}
wordToWordBg
(
node
,
target
)
{
cc
.
tween
(
node
).
to
(
0.2
,
{
x
:
target
.
x
,
y
:
target
.
y
,
scale
:
0.85
})
.
call
(()
=>
{
target
.
active
=
false
;
}).
start
();
}
startCurrentItemAni
()
{
let
childs
=
this
.
currentItem
.
data
;
childs
.
forEach
(
child
=>
{
cc
.
tween
(
child
).
to
(
0.15
,
{
scaleX
:
1.1
,
scaleY
:
0.9
}).
to
(
0.15
,
{
scaleX
:
1
,
scaleY
:
1
}).
delay
(
0.25
).
union
().
repeatForever
().
start
();
})
}
stopCurrentItemAni
()
{
let
childs
=
this
.
currentItem
.
data
;
childs
.
forEach
(
child
=>
{
cc
.
Tween
.
stopAllByTarget
(
child
)
})
}
getBgNodeByGroupIndex
(
group
,
index
)
{
getBgNodeByGroupIndex
(
group
,
index
)
{
let
groupNode
=
this
.
wordBgList
.
find
(
node
=>
{
let
groupNode
=
this
.
wordBgList
.
find
(
node
=>
{
return
node
.
data
.
group
==
group
&&
node
.
data
.
index
==
index
;
return
node
.
data
.
group
==
group
&&
node
.
data
.
index
==
index
;
})
})
return
groupNode
;
return
groupNode
;
}
}
private
count
:
number
;
initGame
()
{
}
startPlay
()
{
}
gameOver
()
{
}
updateLayer
(
layer
,
data
)
{
}
onTouchVoice
(
e
)
{
}
playLocalAudio
(
audioName
)
{
playLocalAudio
(
audioName
)
{
const
audio
=
cc
.
find
(
`Canvas/res/audio/
${
audioName
}
`
).
getComponent
(
cc
.
AudioSource
);
const
audio
=
cc
.
find
(
`Canvas/res/audio/
${
audioName
}
`
).
getComponent
(
cc
.
AudioSource
);
return
new
Promise
((
resolve
,
reject
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
...
...
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