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
15b7a9c9
Commit
15b7a9c9
authored
Dec 18, 2023
by
Tt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
拖拽完成
parent
b90528b3
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
176 additions
and
182 deletions
+176
-182
dg28_drag.fire
assets/dg18_danci/scene/dg28_drag.fire
+142
-163
dg28_drag.ts
assets/dg18_danci/scene/dg28_drag.ts
+34
-19
No files found.
assets/dg18_danci/scene/dg28_drag.fire
View file @
15b7a9c9
This diff is collapsed.
Click to expand it.
assets/dg18_danci/scene/dg28_drag.ts
View file @
15b7a9c9
...
@@ -70,6 +70,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -70,6 +70,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
@
property
(
cc
.
Node
)
layout_canvas
:
cc
.
Node
=
null
;
@
property
(
cc
.
Node
)
layout_canvas
:
cc
.
Node
=
null
;
@
property
(
cc
.
Node
)
layout_items
:
cc
.
Node
=
null
;
@
property
(
cc
.
Node
)
layout_items
:
cc
.
Node
=
null
;
@
property
(
cc
.
Node
)
layout_target
:
cc
.
Node
=
null
;
@
property
(
cc
.
Node
)
layout_battery_left
:
cc
.
Node
=
null
;
@
property
(
cc
.
Node
)
layout_battery_left
:
cc
.
Node
=
null
;
@
property
(
cc
.
Node
)
layout_battery_right
:
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_text
:
cc
.
Node
=
null
;
...
@@ -78,10 +79,9 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -78,10 +79,9 @@ export default class SceneComponent extends MyCocosSceneComponent {
let
img
=
pg
.
view
.
find
(
this
.
layout_canvas
,
'
img
'
);
let
img
=
pg
.
view
.
find
(
this
.
layout_canvas
,
'
img
'
);
pg
.
view
.
setNetImg
(
img
,
this
.
currentQuestion
.
bgItem
.
url
,
{
w
:
1220
,
h
:
790
},
false
)
pg
.
view
.
setNetImg
(
img
,
this
.
currentQuestion
.
bgItem
.
url
,
{
w
:
1220
,
h
:
790
},
false
)
this
.
init
Debug
();
this
.
init
Targets
();
}
}
initDebug
()
{
initTargets
()
{
let
layout_debug
=
pg
.
view
.
find
(
this
,
'
layout_debug
'
);
let
item_color
=
pg
.
view
.
find
(
this
,
'
item_color
'
);
let
item_color
=
pg
.
view
.
find
(
this
,
'
item_color
'
);
let
arr
=
this
.
changepoints
(
this
.
currentQuestion
);
let
arr
=
this
.
changepoints
(
this
.
currentQuestion
);
arr
.
forEach
((
ar
)
=>
{
arr
.
forEach
((
ar
)
=>
{
...
@@ -89,8 +89,8 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -89,8 +89,8 @@ export default class SceneComponent extends MyCocosSceneComponent {
node
.
x
=
ar
.
pos
.
x
;
node
.
x
=
ar
.
pos
.
x
;
node
.
y
=
ar
.
pos
.
y
;
node
.
y
=
ar
.
pos
.
y
;
node
.
data
=
ar
;
node
.
data
=
ar
;
//
node.removeComponent(cc.Sprite);
node
.
removeComponent
(
cc
.
Sprite
);
layout_debug
.
addChild
(
node
)
this
.
layout_target
.
addChild
(
node
)
console
.
log
(
node
.
x
,
node
.
y
)
console
.
log
(
node
.
x
,
node
.
y
)
})
})
}
}
...
@@ -188,11 +188,15 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -188,11 +188,15 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
else
{
}
else
{
// 未碰撞到
// 未碰撞到
// 判定碰撞坐标和区域
// 判定碰撞坐标和区域
let
target
=
this
.
checkSuccess
(
node
)
let
target
Data
=
this
.
checkSuccess
(
node
)
if
(
!
target
)
{
if
(
!
target
Data
)
{
this
.
onMeetFail
(
node
);
this
.
onMeetFail
(
node
);
}
else
{
}
else
{
this
.
onMeetSuccess
(
node
);
if
(
node
.
data
.
index
!=
targetData
.
index
)
{
this
.
onMeetFail
(
node
);
}
else
{
this
.
onMeetSuccess
(
node
,
targetData
);
}
}
}
}
}
}
}
...
@@ -202,16 +206,18 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -202,16 +206,18 @@ export default class SceneComponent extends MyCocosSceneComponent {
let
question
=
this
.
currentQuestion
let
question
=
this
.
currentQuestion
let
arr
=
this
.
changepoints
(
question
)
let
arr
=
this
.
changepoints
(
question
)
// 左上角坐标
// 左上角坐标
// let items =
let
targetData
=
null
;
let
minDis
=
999999
;
return
arr
.
find
(
ar
=>
{
let
items
=
this
.
layout_target
.
children
;
let
dis
=
this
.
getDistances
(
cc
.
v2
(
ar
.
pos
),
node
);
items
.
forEach
((
item
,
i
)
=>
{
if
(
dis
<
100
)
{
let
data
=
item
.
data
;
return
true
let
dis
=
this
.
getDistances
(
item
,
node
);
}
else
{
if
(
dis
<
100
&&
dis
<
minDis
)
{
return
false
minDis
=
dis
;
targetData
=
data
;
}
}
});
})
return
targetData
}
}
private
changepoints
(
data
)
{
private
changepoints
(
data
)
{
...
@@ -232,11 +238,17 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -232,11 +238,17 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
}
onMeetSuccess
(
node
)
{
onMeetSuccess
(
node
,
targetData
)
{
node
.
off
(
cc
.
Node
.
EventType
.
TOUCH_START
,
this
.
onTouchStart
,
this
);
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_MOVE
,
this
.
onTouchMove
,
this
);
node
.
off
(
cc
.
Node
.
EventType
.
TOUCH_END
,
this
.
onTouchEnd
,
this
);
node
.
off
(
cc
.
Node
.
EventType
.
TOUCH_END
,
this
.
onTouchEnd
,
this
);
node
.
off
(
cc
.
Node
.
EventType
.
TOUCH_CANCEL
,
this
.
onTouchEnd
,
this
);
node
.
off
(
cc
.
Node
.
EventType
.
TOUCH_CANCEL
,
this
.
onTouchEnd
,
this
);
node
.
x
=
targetData
.
pos
.
x
;
node
.
y
=
targetData
.
pos
.
y
;
node
.
parent
=
this
.
layout_items
// 处理完成就结束了
}
}
onMeetFail
(
node
)
{
onMeetFail
(
node
)
{
node
.
x
=
node
.
cPos
.
x
;
node
.
x
=
node
.
cPos
.
x
;
...
@@ -252,10 +264,13 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -252,10 +264,13 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
}
private
getDistances
(
p1
,
p
2
)
{
private
getDistances
(
node1
,
node
2
)
{
//转换世界坐标查看距离
//转换世界坐标查看距离
let
p1
=
node1
.
convertToWorldSpaceAR
(
cc
.
v2
(
0
,
0
));
let
p2
=
node2
.
convertToWorldSpaceAR
(
cc
.
v2
(
0
,
0
));
let
temp
=
p1
.
sub
(
p2
);
let
temp
=
p1
.
sub
(
p2
);
let
dis
=
Math
.
abs
(
temp
.
mag
());
let
dis
=
Math
.
abs
(
temp
.
mag
());
console
.
log
(
`
${
p1
.
x
}
,
${
p1
.
y
}
`
,
`
${
p2
.
x
}
,
${
p2
.
y
}
`
,
dis
);
return
dis
;
return
dis
;
}
}
private
rectCollect
(
A
,
B
)
{
private
rectCollect
(
A
,
B
)
{
...
...
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