Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
PicturePuzzle
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
PicturePuzzle
Commits
7bb1f772
Commit
7bb1f772
authored
Mar 07, 2020
by
李维
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dev commit
parent
6f55fbcd
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
39 deletions
+24
-39
Unit.ts
src/app/common/custom-hot-zone/Unit.ts
+7
-10
custom-hot-zone.component.html
...app/common/custom-hot-zone/custom-hot-zone.component.html
+1
-1
custom-hot-zone.component.ts
src/app/common/custom-hot-zone/custom-hot-zone.component.ts
+16
-28
No files found.
src/app/common/custom-hot-zone/Unit.ts
View file @
7bb1f772
...
...
@@ -505,15 +505,17 @@ export class HotZoneImageItem extends MySprite {
image
:
MySprite
;
imageSrc
:
String
;
labelBox
:
MySprite
;
scale
text
;
arrowTop
;
arrowRight
;
init
(
imageSrc
=
null
){
this
.
showImage
(
imageSrc
,(
img
)
=>
{
init
(
imageSrc
=
null
,
initWidth
,
initHeight
,
callback
?
){
this
.
showImage
(
imageSrc
,
initWidth
,
initHeight
,
(
img
)
=>
{
console
.
log
(
"
Init
"
)
callback
&&
callback
(
img
.
width
,
img
.
height
)
this
.
setSize
(
img
.
width
*
this
.
image
.
scaleX
,
img
.
height
*
this
.
image
.
scaleY
)
this
.
lineDashFlag
=
true
;
this
.
showLineDash
()
...
...
@@ -534,7 +536,6 @@ export class HotZoneImageItem extends MySprite {
this
.
labelBox
.
x
=
this
.
labelBox
.
width
/
2
;
this
.
labelBox
.
y
=
this
.
labelBox
.
height
/
2
;
});
this
.
label
=
new
Label
(
this
.
ctx
);
// this.label.anchorY = 0;
this
.
label
.
fontSize
=
'
30px
'
;
...
...
@@ -550,7 +551,6 @@ export class HotZoneImageItem extends MySprite {
}
else
if
(
this
.
text
)
{
this
.
label
.
text
=
this
.
text
;
}
this
.
label
.
visible
=
true
;
}
...
...
@@ -559,20 +559,17 @@ export class HotZoneImageItem extends MySprite {
this
.
label
.
visible
=
false
;
}
showImage
(
imageSrc
=
null
,
callback
)
{
showImage
(
imageSrc
=
null
,
initWidth
,
initHeight
,
callback
)
{
this
.
loadImage
(
imageSrc
).
then
((
img
)
=>
{
if
(
this
.
image
){
this
.
removeChild
(
this
.
image
)
}
this
.
image
=
new
MySprite
(
this
.
ctx
);
this
.
image
.
init
(
img
)
let
scale
=
Math
.
min
(
200
/
this
.
image
.
width
,
200
/
this
.
image
.
height
)
this
.
image
.
x
=
this
.
image
.
width
*
scale
/
2
this
.
image
.
y
=
this
.
image
.
height
*
scale
/
2
this
.
image
.
x
=
this
.
image
.
width
/
2
this
.
image
.
y
=
this
.
image
.
height
/
2
this
.
image
.
alpha
=
0.7
;
this
.
image
.
setScaleXY
(
scale
);
this
.
addChild
(
this
.
image
,
-
1
);
this
.
imageSrc
=
img
.
src
;
callback
&&
callback
(
this
.
image
)
})
}
...
...
src/app/common/custom-hot-zone/custom-hot-zone.component.html
View file @
7bb1f772
...
...
@@ -39,7 +39,7 @@
<div
class=
"img-box-upload"
>
<app-upload-image-with-preview
[
picUrl
]="
it
.
pic_url
"
[
picUrl
]="
it
.
imageSrc
"
(
imageUploaded
)="
onImgUploadSuccessByImg
($
event
,
it
,
i
)"
>
</app-upload-image-with-preview>
</div>
...
...
src/app/common/custom-hot-zone/custom-hot-zone.component.ts
View file @
7bb1f772
...
...
@@ -20,7 +20,6 @@ export class CustomHotZoneComponent implements OnInit, OnDestroy, OnChanges {
@
Input
()
set
bgItem
(
v
)
{
this
.
_bgItem
=
v
;
this
.
init
();
}
get
bgItem
()
{
...
...
@@ -64,7 +63,6 @@ export class CustomHotZoneComponent implements OnInit, OnDestroy, OnChanges {
// 声音
bgAudio
=
new
Audio
();
images
=
new
Map
();
animationId
:
any
;
...
...
@@ -100,12 +98,10 @@ export class CustomHotZoneComponent implements OnInit, OnDestroy, OnChanges {
ngOnInit
()
{
this
.
initListener
();
console
.
log
(
"
init
"
)
// this.init();
this
.
update
();
}
ngOnDestroy
()
{
...
...
@@ -126,12 +122,10 @@ export class CustomHotZoneComponent implements OnInit, OnDestroy, OnChanges {
}
refreshBackground
(
callBack
=
null
)
{
if
(
!
this
.
bg
)
{
this
.
bg
=
new
MySprite
(
this
.
ctx
);
this
.
renderArr
.
push
(
this
.
bg
);
}
const
bg
=
this
.
bg
;
if
(
this
.
bgItem
.
url
)
{
bg
.
load
(
this
.
bgItem
.
url
).
then
(()
=>
{
...
...
@@ -146,7 +140,6 @@ export class CustomHotZoneComponent implements OnInit, OnDestroy, OnChanges {
}
});
}
}
...
...
@@ -158,8 +151,8 @@ export class CustomHotZoneComponent implements OnInit, OnDestroy, OnChanges {
}
onImgUploadSuccessByImg
(
e
,
img
,
index
)
{
// console.log(
)
this
.
hotZoneArr
[
index
]
.
init
(
e
.
url
)
console
.
log
(
img
)
img
.
init
(
e
.
url
)
img
.
pic_url
=
e
.
url
;
this
.
refreshImage
(
img
);
}
...
...
@@ -176,7 +169,6 @@ export class CustomHotZoneComponent implements OnInit, OnDestroy, OnChanges {
this
.
hotZoneArr
[
i
].
index
=
i
;
if
(
this
.
hotZoneArr
[
i
])
{
this
.
hotZoneArr
[
i
].
text
=
(
i
+
1
);
}
}
}
...
...
@@ -185,12 +177,10 @@ export class CustomHotZoneComponent implements OnInit, OnDestroy, OnChanges {
refreshImageId
()
{
for
(
let
i
=
0
;
i
<
this
.
imgArr
.
length
;
i
++
)
{
this
.
imgArr
[
i
].
id
=
i
;
if
(
this
.
imgArr
[
i
].
picItem
)
{
this
.
imgArr
[
i
].
picItem
.
text
=
'
Image-
'
+
(
i
+
1
);
}
}
}
getHotZoneItem
(
saveData
=
null
)
{
...
...
@@ -198,24 +188,25 @@ export class CustomHotZoneComponent implements OnInit, OnDestroy, OnChanges {
const
itemH
=
200
;
const
item
=
new
HotZoneImageItem
(
this
.
ctx
);
if
(
saveData
){
item
.
init
(
saveData
.
rect
.
src
);
item
.
init
(
saveData
.
rect
.
src
,
saveData
.
rect
.
width
,
saveData
.
rect
.
height
,
(
w
,
h
)
=>
{
const
saveRect
=
saveData
.
rect
;
item
.
scaleX
=
saveData
.
rect
.
width
/
w
;
item
.
scaleY
=
saveData
.
rect
.
height
/
h
;
item
.
x
=
saveRect
.
x
// + saveRect.width / 2 ;
item
.
y
=
saveRect
.
y
// + saveRect.height / 2;
if
(
saveData
.
rect
.
src
.
indexOf
(
"
bg_200_200
"
)
==
-
1
){
item
.
imageSrc
=
saveData
.
rect
.
src
}
});
}
else
{
item
.
init
(
"
assets/default/bg_200_200.png
"
);
item
.
init
(
"
assets/default/bg_200_200.png
"
,
200
,
200
,
()
=>
{
item
.
imageSrc
=
""
});
}
item
.
anchorX
=
0.5
;
item
.
anchorY
=
0.5
;
item
.
x
=
this
.
canvasWidth
/
2
-
100
;
item
.
y
=
this
.
canvasHeight
/
2
-
100
;
if
(
saveData
)
{
const
saveRect
=
saveData
.
rect
;
item
.
scaleX
=
saveRect
.
width
/
item
.
width
;
item
.
scaleY
=
saveRect
.
height
/
item
.
height
;
item
.
x
=
saveRect
.
x
+
saveRect
.
width
/
2
;
item
.
y
=
saveRect
.
y
+
saveRect
.
height
/
2
;
}
return
item
;
}
...
...
@@ -263,8 +254,6 @@ export class CustomHotZoneComponent implements OnInit, OnDestroy, OnChanges {
this
.
refreshHotZoneId
();
}
init
()
{
this
.
initData
();
this
.
initCtx
();
...
...
@@ -283,7 +272,6 @@ export class CustomHotZoneComponent implements OnInit, OnDestroy, OnChanges {
}
});
}
}
initHotZoneArr
()
{
...
...
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