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
54933023
Commit
54933023
authored
Jul 30, 2024
by
limingzhe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: debug
parent
a8cb6846
Changes
4
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
180 additions
and
129 deletions
+180
-129
.DS_Store
.DS_Store
+0
-0
dg18_tianci.ts
assets/dg18_tianci/scene/dg18_tianci.ts
+56
-15
pg_dg18_tianci.ts
assets/dg18_tianci/scene/pg_dg18_tianci.ts
+11
-4
defaultData_dg18_tianci.ts
assets/dg18_tianci/script/defaultData_dg18_tianci.ts
+113
-110
No files found.
.DS_Store
View file @
54933023
No preview for this file type
assets/dg18_tianci/scene/dg18_tianci.ts
View file @
54933023
...
@@ -96,7 +96,13 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -96,7 +96,13 @@ 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
},
true
).
then
(()
=>
{
pg
.
view
.
setNetImg
(
img
,
this
.
currentQuestion
.
bgItem
.
url
,
{
w
:
1220
,
h
:
790
},
true
).
then
(()
=>
{
this
.
initTargets
(
img
);
this
.
initTargets
(
img
);
if
(
this
.
current
!=
0
)
{
this
.
layout_target
.
children
.
forEach
(
nd
=>
{
nd
.
opacity
=
255
})
}
})
})
if
(
this
.
current
==
0
)
{
if
(
this
.
current
==
0
)
{
...
@@ -117,18 +123,25 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -117,18 +123,25 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
}
}
}
initTargets
(
img
)
{
initTargets
(
img
)
{
console
.
log
(
'
in initTargets
'
)
this
.
layout_target
.
removeAllChildren
();
this
.
layout_target
.
removeAllChildren
();
let
item_color
=
pg
.
view
.
find
(
this
,
'
item_color
'
);
let
item_color
=
pg
.
view
.
find
(
this
,
'
item_color
'
);
let
boxHeight
=
this
.
layout_canvas
.
height
;
// let boxHeight = this.layout_canvas.height;
let
imgHeight
=
img
.
height
;
// let imgHeight = img.height;
let
moveY
=
(
boxHeight
-
imgHeight
)
/
2
// let moveY = (boxHeight - imgHeight) / 2
let
arr
=
this
.
changepoints
(
this
.
currentQuestion
,
moveY
);
this
.
layout_target
.
scale
=
img
.
scale
;
this
.
layout_items
.
scale
=
img
.
scale
;
let
arr
=
this
.
changepoints
(
this
.
currentQuestion
,
img
);
// 整体的坐标需要往中间下面进行计算。
// 整体的坐标需要往中间下面进行计算。
arr
.
forEach
((
ar
)
=>
{
arr
.
forEach
((
ar
)
=>
{
let
node
=
pg
.
view
.
clone
(
item_color
);
let
node
=
pg
.
view
.
clone
(
item_color
);
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
.
opacity
=
0
;
node
.
opacity
=
0
;
node
.
removeComponent
(
cc
.
Sprite
);
node
.
removeComponent
(
cc
.
Sprite
);
...
@@ -316,18 +329,45 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -316,18 +329,45 @@ export default class SceneComponent extends MyCocosSceneComponent {
return
{
targetData
,
targetItem
}
return
{
targetData
,
targetItem
}
}
}
private
changepoints
(
data
,
moveY
)
{
private
changepoints
(
data
,
bgImg
)
{
let
scaleX
=
1220
/
data
.
bgItem
.
rect
.
width
;
let
scaleY
=
790
/
data
.
bgItem
.
rect
.
height
;
const
rate
=
(
bgImg
.
scale
*
bgImg
.
width
)
/
data
.
bgItem
.
rect
.
width
;
let
scale
=
scaleX
<=
scaleY
?
scaleX
:
scaleY
;
const
scale
=
rate
/
bgImg
.
scaleY
;
return
data
.
hotZoneItemArr
.
map
((
item
,
idx
)
=>
{
return
data
.
hotZoneItemArr
.
map
((
item
,
idx
)
=>
{
let
rect
=
item
.
rect
;
let
rect
=
item
.
rect
;
item
.
pos
=
{
x
:
(
rect
.
x
+
(
rect
.
width
/
2
))
*
scale
,
item
.
pos
=
{};
y
:
-
((
rect
.
y
+
(
rect
.
height
/
2
))
*
scale
)
-
moveY
}
const
rectNode
=
new
cc
.
Node
();
item
.
width
=
rect
.
width
*
scale
;
rectNode
.
name
=
'
rect
'
+
data
.
index
;
item
.
height
=
rect
.
height
*
scale
;
bgImg
.
addChild
(
rectNode
);
const
ctx
=
rectNode
.
addComponent
(
cc
.
Graphics
);
// 矩形
ctx
.
lineWidth
=
4
;
ctx
.
strokeColor
=
cc
.
Color
.
BLACK
;
ctx
.
fillColor
=
cc
.
Color
.
WHITE
.
setA
(
100
);
// const scale = rate / bgImg.scaleY;
rectNode
.
width
=
rect
.
width
*
scale
;
rectNode
.
height
=
rect
.
height
*
scale
;
rectNode
.
x
=
-
bgImg
.
width
/
2
+
rect
.
x
*
scale
;
rectNode
.
y
=
bgImg
.
height
/
2
-
rect
.
height
*
scale
-
rect
.
y
*
scale
;
rectNode
.
anchorX
=
rectNode
.
anchorY
=
0
;
ctx
.
rect
(
0
,
0
,
rectNode
.
width
,
rectNode
.
height
);
// ctx.stroke();
// ctx.fill();
item
.
width
=
rectNode
.
width
;
item
.
height
=
rectNode
.
height
;
const
worldPos
=
bgImg
.
convertToWorldSpaceAR
(
cc
.
v2
(
rectNode
.
x
+
rectNode
.
width
/
2
,
rectNode
.
y
+
rectNode
.
height
/
2
));
const
newPos
=
this
.
layout_target
.
convertToNodeSpaceAR
(
worldPos
);
item
.
pos
.
x
=
newPos
.
x
;
item
.
pos
.
y
=
newPos
.
y
;
// item.width = rect.width * scale;
// item.height = rect.height * scale;
return
item
;
return
item
;
})
})
}
}
...
@@ -349,6 +389,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -349,6 +389,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
let
text2
=
pg
.
view
.
find
(
node
,
'
text_2
'
);
let
text2
=
pg
.
view
.
find
(
node
,
'
text_2
'
);
text1
.
active
=
false
;
text1
.
active
=
false
;
text2
.
active
=
false
;
text2
.
active
=
false
;
text
.
parent
.
scale
=
1
/
this
.
layout_items
.
scale
;
pg
.
view
.
setColor
(
text
,
'
#1D8B38
'
)
pg
.
view
.
setColor
(
text
,
'
#1D8B38
'
)
text
.
getComponent
(
cc
.
Label
).
fontSize
=
targetData
.
fontSize
;
text
.
getComponent
(
cc
.
Label
).
fontSize
=
targetData
.
fontSize
;
...
...
assets/dg18_tianci/scene/pg_dg18_tianci.ts
View file @
54933023
import
{
width
}
from
'
./../../../form/node_modules/@fortawesome/free-regular-svg-icons/faAddressCard.d
'
;
class
Emitter
{
class
Emitter
{
static
instance
;
static
instance
;
static
getInstance
()
{
static
getInstance
()
{
...
@@ -292,13 +293,19 @@ let pg = {
...
@@ -292,13 +293,19 @@ let pg = {
let
scaleX
=
w
/
nw
;
let
scaleX
=
w
/
nw
;
let
scaleY
=
h
/
nh
;
let
scaleY
=
h
/
nh
;
let
scale
=
scaleX
<=
scaleY
?
scaleX
:
scaleY
;
let
scale
=
scaleX
<=
scaleY
?
scaleX
:
scaleY
;
node
.
width
=
nw
*
scale
;
// node.width = nw * scale;
node
.
height
=
nh
*
scale
;
// node.height = nh * scale;
node
.
scale
=
scale
;
}
else
{
}
else
{
let
scaleX
=
w
/
nw
;
let
scaleX
=
w
/
nw
;
let
scaleY
=
h
/
nh
;
let
scaleY
=
h
/
nh
;
node
.
width
=
nw
*
scaleX
;
let
scale
=
scaleX
<=
scaleY
?
scaleX
:
scaleY
;
node
.
height
=
nh
*
scaleY
;
// node.width = nw * scaleX;
// node.height = nh * scaleY;
node
.
scale
=
scale
;
}
}
node
.
active
=
nodeActive
;
node
.
active
=
nodeActive
;
resolve
({
w
:
nw
,
h
:
nh
});
resolve
({
w
:
nw
,
h
:
nh
});
...
...
assets/dg18_tianci/script/defaultData_dg18_tianci.ts
View file @
54933023
This diff is collapsed.
Click to expand it.
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