Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
dg18_tianci
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
dg18_tianci
Commits
68fb93cd
Commit
68fb93cd
authored
Dec 18, 2023
by
Tt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
基础部分完成
parent
0c5eb5b6
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
880 additions
and
258 deletions
+880
-258
dg28_drag.fire
assets/dg18_danci/scene/dg28_drag.fire
+763
-236
dg28_drag.ts
assets/dg18_danci/scene/dg28_drag.ts
+108
-17
pg_dg28_drag.ts
assets/dg18_danci/scene/pg_dg28_drag.ts
+6
-1
defaultData_dg28_drag.ts
assets/dg18_danci/script/defaultData_dg28_drag.ts
+2
-4
creator.d.ts
creator.d.ts
+1
-0
No files found.
assets/dg18_danci/scene/dg28_drag.fire
View file @
68fb93cd
This diff is collapsed.
Click to expand it.
assets/dg18_danci/scene/dg28_drag.ts
View file @
68fb93cd
...
...
@@ -69,13 +69,14 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
@
property
(
cc
.
Node
)
layout_canvas
:
cc
.
Node
=
null
;
@
property
(
cc
.
Node
)
layout_items
:
cc
.
Node
=
null
;
@
property
(
cc
.
Node
)
layout_battery_left
:
cc
.
Node
=
null
;
@
property
(
cc
.
Node
)
layout_battery_right
:
cc
.
Node
=
null
;
@
property
(
cc
.
Node
)
item_battery_text
:
cc
.
Node
=
null
;
@
property
(
cc
.
Node
)
item_battery_img
:
cc
.
Node
=
null
;
updateCanvas
()
{
let
img
=
pg
.
view
.
find
(
this
.
layout_canvas
,
'
img
'
);
pg
.
view
.
setNetImg
(
img
,
this
.
currentQuestion
.
bgItem
.
url
,
{
w
:
1220
,
h
:
790
})
pg
.
view
.
setNetImg
(
img
,
this
.
currentQuestion
.
bgItem
.
url
,
{
w
:
1220
,
h
:
790
}
,
false
)
}
initLayoutBattery
()
{
let
color
=
1
;
...
...
@@ -95,6 +96,8 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
if
(
data
.
itemType
==
'
text
'
)
{
let
item
=
pg
.
view
.
clone
(
this
.
item_battery_text
)
let
item_text
=
pg
.
view
.
find
(
item
,
'
item_text
'
);
pg
.
view
.
setString
(
pg
.
view
.
find
(
item_text
,
'
text
'
),
data
.
text
)
if
(
isleft
)
{
// 左侧
pg
.
view
.
visible
(
pg
.
view
.
find
(
item
,
'
bg/img_battery
'
+
1
),
i
==
0
)
...
...
@@ -105,6 +108,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
// 右侧
pg
.
view
.
visible
(
pg
.
view
.
find
(
item
,
'
bg/img_battery
'
+
5
),
i
==
4
||
i
==
6
)
pg
.
view
.
visible
(
pg
.
view
.
find
(
item
,
'
bg/img_battery
'
+
6
),
i
==
5
||
i
==
7
)
item_text
.
x
=
20
}
item
.
active
=
true
;
item
.
x
=
0
;
...
...
@@ -112,23 +116,111 @@ export default class SceneComponent extends MyCocosSceneComponent {
item
.
y
=
lastY
-=
spaceTextY
;
layout
.
addChild
(
item
);
lastY
=
item
.
y
;
item_text
.
data
=
data
;
color
++
;
if
(
color
>
6
)
color
=
1
;
item_text
.
on
(
cc
.
Node
.
EventType
.
TOUCH_START
,
this
.
onTouchStart
,
this
);
item_text
.
on
(
cc
.
Node
.
EventType
.
TOUCH_MOVE
,
this
.
onTouchMove
,
this
);
item_text
.
on
(
cc
.
Node
.
EventType
.
TOUCH_END
,
this
.
onTouchEnd
,
this
);
item_text
.
on
(
cc
.
Node
.
EventType
.
TOUCH_CANCEL
,
this
.
onTouchEnd
,
this
);
}
else
if
(
data
.
itemType
==
'
pic
'
)
{
let
item
=
pg
.
view
.
clone
(
this
.
item_battery_img
)
let
item_img
=
pg
.
view
.
find
(
item
,
'
item_img
'
);
pg
.
view
.
setNetImg
(
pg
.
view
.
find
(
item_img
,
'
img
'
),
data
.
pic_url
,
{
w
:
270
,
h
:
180
},
true
)
item
.
active
=
true
;
item
.
x
=
0
;
if
(
!
lastY
&&
lastY
!=
0
)
lastY
=
orgPosY
;
item
.
y
=
lastY
-=
spaceImgY
;
layout
.
addChild
(
item
);
lastY
=
item
.
y
;
item_img
.
data
=
data
;
item_img
.
on
(
cc
.
Node
.
EventType
.
TOUCH_START
,
this
.
onTouchStart
,
this
);
item_img
.
on
(
cc
.
Node
.
EventType
.
TOUCH_MOVE
,
this
.
onTouchMove
,
this
);
item_img
.
on
(
cc
.
Node
.
EventType
.
TOUCH_END
,
this
.
onTouchEnd
,
this
);
item_img
.
on
(
cc
.
Node
.
EventType
.
TOUCH_CANCEL
,
this
.
onTouchEnd
,
this
);
}
console
.
log
(
data
);
})
}
currentTouchNode
:
cc
.
Node
;
onTouchStart
(
event
)
{
let
node
=
event
.
target
;
this
.
currentTouchNode
=
node
;
node
.
cPos
=
cc
.
v2
(
node
);
}
onTouchMove
(
event
)
{
let
node
=
event
.
target
;
if
(
!
node
||
!
node
.
data
)
return
;
if
(
node
!=
this
.
currentTouchNode
)
return
;
node
.
opacity
=
255
;
let
delta
=
event
.
touch
.
getDelta
();
let
pos
=
cc
.
v2
(
delta
);
node
.
x
+=
pos
.
x
;
node
.
y
+=
pos
.
y
;
}
onTouchEnd
(
event
)
{
let
node
=
event
.
target
;
if
(
!
node
||
!
node
.
data
)
return
;
if
(
node
!=
this
.
currentTouchNode
)
return
;
let
x
=
node
.
x
;
let
y
=
node
.
y
;
let
isIn
=
this
.
rectCollect
(
node
,
this
.
layout_canvas
);
if
(
!
isIn
)
{
this
.
onMeetFail
(
node
);
}
else
{
// 未碰撞到
// 判定碰撞坐标和区域
let
target
=
this
.
checkSuccess
(
node
)
if
(
!
target
)
{
this
.
onMeetFail
(
node
);
}
else
{
this
.
onMeetSuccess
(
node
);
}
}
}
// 检测碰撞成功需要重新编写
checkSuccess
(
node
)
{
let
question
=
this
.
currentQuestion
let
arr
=
this
.
changepoints
(
question
)
return
arr
.
find
(
ar
=>
{
let
dis
=
this
.
getDistances
(
cc
.
v2
(
ar
.
pos
),
node
);
if
(
dis
<
100
)
{
return
true
}
else
{
return
false
}
});
}
private
changepoints
(
data
)
{
let
scX
=
1560
/
data
.
bgItem
.
rect
.
width
;
let
scY
=
720
/
data
.
bgItem
.
rect
.
height
;
let
px
=
data
.
bgItem
.
rect
.
x
;
let
py
=
data
.
bgItem
.
rect
.
y
;
return
data
.
hotZoneItemArr
.
map
((
item
,
idx
)
=>
{
let
rect
=
item
.
rect
;
item
.
pos
=
{
x
:
(
rect
.
x
+
(
rect
.
width
/
2
))
*
scX
,
y
:
-
((
rect
.
y
+
(
rect
.
height
/
2
))
*
scY
)
}
item
.
width
=
rect
.
width
*
scX
;
item
.
height
=
rect
.
height
*
scY
;
return
item
;
})
}
onMeetSuccess
(
node
)
{
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
);
node
.
off
(
cc
.
Node
.
EventType
.
TOUCH_CANCEL
,
this
.
onTouchEnd
,
this
);
}
onMeetFail
(
node
)
{
node
.
x
=
node
.
cPos
.
x
;
node
.
y
=
node
.
cPos
.
y
;
}
private
waitTime
:
number
;
update
(
dt
)
{
if
(
!
this
.
waitTime
)
this
.
waitTime
=
8
;
...
...
@@ -139,6 +231,21 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
private
getDistances
(
p1
,
p2
)
{
//转换世界坐标查看距离
let
temp
=
p1
.
sub
(
p2
);
let
dis
=
Math
.
abs
(
temp
.
mag
());
return
dis
;
}
private
rectCollect
(
A
,
B
)
{
let
AP
=
A
.
convertToWorldSpaceAR
(
cc
.
v2
(
0
,
0
));
let
BP
=
B
.
convertToWorldSpaceAR
(
cc
.
v2
(
0
,
0
));
if
(
Math
.
abs
(
AP
.
x
-
BP
.
x
)
<
A
.
width
/
2
+
B
.
width
/
2
&&
Math
.
abs
(
AP
.
y
-
BP
.
y
)
<
A
.
height
/
2
+
B
.
height
/
2
)
return
true
;
return
false
;
}
showXiaodi
()
{
if
(
!
this
.
data
.
npcAudioEnd
)
return
;
pg
.
view
.
find
(
this
,
'
layout_xiaodi/btn_go
'
).
active
=
false
;
...
...
@@ -175,22 +282,6 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
}
private
changepoints
(
data
)
{
let
scX
=
1560
/
data
.
bgItem
.
rect
.
width
;
let
scY
=
720
/
data
.
bgItem
.
rect
.
height
;
let
px
=
data
.
bgItem
.
rect
.
x
;
let
py
=
data
.
bgItem
.
rect
.
y
;
let
pointsArr
=
[];
let
arr
=
[];
data
.
hotZoneItemArr
.
forEach
((
item
,
idx
)
=>
{
let
p
=
item
.
rect
;
arr
[
idx
]
=
{
x
:
(
p
.
x
+
(
p
.
width
/
2
))
*
scX
,
// - px
y
:
-
((
p
.
y
+
(
p
.
height
/
2
))
*
scY
)
// - py
}
})
pointsArr
=
arr
.
concat
();
}
playLocalAudio
(
audioName
)
{
const
audio
=
cc
.
find
(
`Canvas/res/audio/
${
audioName
}
`
).
getComponent
(
cc
.
AudioSource
);
return
new
Promise
((
resolve
,
reject
)
=>
{
...
...
assets/dg18_danci/scene/pg_dg28_drag.ts
View file @
68fb93cd
...
...
@@ -291,9 +291,14 @@ let pg = {
if
(
w
&&
h
&&
custom
)
{
let
scaleX
=
w
/
nw
;
let
scaleY
=
h
/
nh
;
let
scale
=
scaleX
<=
scaleY
?
scale
Y
:
scaleX
;
let
scale
=
scaleX
<=
scaleY
?
scale
X
:
scaleY
;
node
.
width
=
nw
*
scale
;
node
.
height
=
nh
*
scale
;
}
else
{
let
scaleX
=
w
/
nw
;
let
scaleY
=
h
/
nh
;
node
.
width
=
nw
*
scaleX
;
node
.
height
=
nh
*
scaleY
;
}
node
.
active
=
nodeActive
;
resolve
({
w
:
nw
,
h
:
nh
});
...
...
assets/dg18_danci/script/defaultData_dg28_drag.ts
View file @
68fb93cd
...
...
@@ -38,11 +38,9 @@ export const defaultData =
},
{
"
index
"
:
4
,
"
text
"
:
"
part5
"
,
"
itemType
"
:
"
text
"
,
"
fontSize
"
:
50
,
"
fontName
"
:
"
BRLNSR_1
"
,
"
fontColor
"
:
"
#8f3758
"
,
"
fontScale
"
:
0.853125
,
"
imgScale
"
:
1
,
"
mapScale
"
:
0.853125
,
"
rect
"
:
{
"
x
"
:
883.89
,
"
y
"
:
460.5
,
"
width
"
:
200
,
"
height
"
:
200
}
},
{
"
index
"
:
5
,
"
text
"
:
"
part6
"
,
"
itemType
"
:
"
text
"
,
"
fontSize
"
:
50
,
"
fontName
"
:
"
BRLNSR_1
"
,
"
fontColor
"
:
"
#8f3758
"
,
"
fontScale
"
:
0.853125
,
"
imgScale
"
:
1
,
"
mapScale
"
:
0.853125
,
"
rect
"
:
{
"
x
"
:
469.89
,
"
y
"
:
-
70
.5
,
"
width
"
:
200
,
"
height
"
:
200
}
"
index
"
:
5
,
"
pic_url
"
:
"
http://staging-teach.cdn.ireadabc.com/be8ec5cee7a3074440478b00a4a84f5e.png
"
,
"
itemType
"
:
"
pic
"
,
"
fontSize
"
:
50
,
"
fontName
"
:
"
BRLNSR_1
"
,
"
fontColor
"
:
"
#8f3758
"
,
"
fontScale
"
:
0.853125
,
"
imgScale
"
:
0.44287909836065575
,
"
mapScale
"
:
0.853125
,
"
rect
"
:
{
"
x
"
:
6.89
,
"
y
"
:
79
.5
,
"
width
"
:
200
,
"
height
"
:
200
}
},
{
"
index
"
:
6
,
"
pic_url
"
:
"
http://staging-teach.cdn.ireadabc.com/be8ec5cee7a3074440478b00a4a84f5e.png
"
,
"
itemType
"
:
"
pic
"
,
"
fontSize
"
:
50
,
"
fontName
"
:
"
BRLNSR_1
"
,
"
fontColor
"
:
"
#8f3758
"
,
"
fontScale
"
:
0.853125
,
"
imgScale
"
:
0.44287909836065575
,
"
mapScale
"
:
0.853125
,
"
rect
"
:
{
"
x
"
:
6.89
,
"
y
"
:
79.5
,
"
width
"
:
200
,
"
height
"
:
200
}
},
{
"
index
"
:
7
,
"
pic_url
"
:
"
http://staging-teach.cdn.ireadabc.com/a5d393ae3c9759211c441f8d3fc69e04.png
"
,
"
itemType
"
:
"
pic
"
,
"
fontSize
"
:
50
,
"
fontName
"
:
"
BRLNSR_1
"
,
"
fontColor
"
:
"
#8f3758
"
,
"
fontScale
"
:
0.853125
,
"
imgScale
"
:
1.1256510416666667
,
"
mapScale
"
:
0.853125
,
"
rect
"
:
{
"
x
"
:
870.89
,
"
y
"
:
294.5
,
"
width
"
:
200
,
"
height
"
:
200
}
"
index
"
:
6
,
"
pic_url
"
:
"
http://staging-teach.cdn.ireadabc.com/a5d393ae3c9759211c441f8d3fc69e04.png
"
,
"
itemType
"
:
"
pic
"
,
"
fontSize
"
:
50
,
"
fontName
"
:
"
BRLNSR_1
"
,
"
fontColor
"
:
"
#8f3758
"
,
"
fontScale
"
:
0.853125
,
"
imgScale
"
:
1.1256510416666667
,
"
mapScale
"
:
0.853125
,
"
rect
"
:
{
"
x
"
:
870.89
,
"
y
"
:
294.5
,
"
width
"
:
200
,
"
height
"
:
200
}
}],
"
hotZoneFontObj
"
:
{
"
size
"
:
50
,
...
...
creator.d.ts
View file @
68fb93cd
...
...
@@ -4588,6 +4588,7 @@ declare namespace cc {
/** !#en Returns a normalized vector representing the forward direction (Z axis) of the node in world space.
!#zh 获取节点正前方(z 轴)面对的方向,返回值为世界坐标系下的归一化向量 */
forward
:
Vec3
;
data
:
any
;
/**
@param name name
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