Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
SSIWB2504
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
SSIWB2504
Commits
7928d53e
Commit
7928d53e
authored
Aug 04, 2025
by
Tt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(play): 添加创建鱼元素功能并更新资源命名
parent
b9e7c71a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
74 additions
and
7 deletions
+74
-7
play.component.ts
src/app/play/play.component.ts
+68
-1
resources.js
src/app/play/resources.js
+6
-6
No files found.
src/app/play/play.component.ts
View file @
7928d53e
...
...
@@ -694,6 +694,10 @@ export class PlayComponent implements OnInit, OnDestroy {
}
else
{
this
.
cat_center
=
this
.
createCat
(
'
center
'
);
// 创建中间猫
}
const
type
=
'
big
'
const
data
=
this
.
g_formData
.
questions
[
0
];
this
.
createFish
(
type
,
data
);
}
initVsView
()
{
...
...
@@ -867,7 +871,70 @@ export class PlayComponent implements OnInit, OnDestroy {
return
cat
;
}
createFish
(
type
,
data
)
{
// 创建鱼元素
const
fish
=
this
.
g_cartoon
.
createCartoonElement
(
'
fish
'
,
'
MySprite
'
);
fish
.
ref
.
init
(
this
.
g_cartoon
.
images
.
get
(
'
fish
'
));
fish
.
ref
.
scaleX
=
this
.
g_mapScale
;
fish
.
ref
.
scaleY
=
this
.
g_mapScale
;
fish
.
ref
.
x
=
this
.
g_canvasWidth
/
2
;
fish
.
ref
.
y
=
this
.
g_canvasHeight
/
2
;
let
itemWidth
=
300
*
this
.
g_mapScale
;
let
itemHeight
=
250
*
this
.
g_mapScale
;
// 背景泡泡
// 创建船节点 - 作为钓鱼台,放在最下方
const
pao_pao_da_png
=
this
.
g_cartoon
.
createCartoonElement
(
'
pao_pao_da_png
'
,
'
MySprite
'
);
pao_pao_da_png
.
ref
.
init
(
this
.
g_cartoon
.
images
.
get
(
'
pao_pao_da_png
'
));
pao_pao_da_png
.
ref
.
scaleX
=
this
.
g_mapScale
;
pao_pao_da_png
.
ref
.
scaleY
=
this
.
g_mapScale
;
pao_pao_da_png
.
ref
.
x
=
0
pao_pao_da_png
.
ref
.
y
=
-
38
fish
.
ref
.
addChild
(
pao_pao_da_png
.
ref
);
// 一条小鱼
const
colors
=
[
'
huang
'
,
'
ju
'
,
'
lan
'
,
'
lv
'
]
const
nameYu
=
colors
[
Math
.
floor
(
Math
.
random
()
*
colors
.
length
)]
+
'
_yu
'
const
xiao_yu
=
this
.
g_cartoon
.
createCartoonElement
(
nameYu
,
'
MySprite
'
);
xiao_yu
.
ref
.
init
(
this
.
g_cartoon
.
images
.
get
(
nameYu
));
xiao_yu
.
ref
.
scaleX
=
this
.
g_mapScale
;
xiao_yu
.
ref
.
scaleY
=
this
.
g_mapScale
;
xiao_yu
.
ref
.
x
=
40
*
this
.
g_mapScale
;
xiao_yu
.
ref
.
y
=
80
*
this
.
g_mapScale
;
fish
.
ref
.
addChild
(
xiao_yu
.
ref
);
// 网络加载的图片
if
(
data
.
image
)
{
const
imageElement
=
this
.
g_cartoon
.
createCartoonElement
(
`fish_image_card`
,
'
MySprite
'
);
this
.
g_cartoon
.
preloadImage
(
data
.
image
).
then
((
img
:
any
)
=>
{
// 图片加载完成后初始化sprite
imageElement
.
ref
.
init
(
img
);
// 设置图片位置居中
imageElement
.
ref
.
x
=
0
;
imageElement
.
ref
.
y
=
-
70
;
// 根据背景卡片尺寸调整图片大小,保持适当的边距,应用屏幕适配参数
const
padding
=
20
;
// 边距
const
maxWidth
=
itemWidth
-
padding
*
2
;
const
maxHeight
=
itemHeight
-
padding
*
2
;
const
scaleX
=
maxWidth
/
img
.
width
;
const
scaleY
=
maxHeight
/
img
.
height
;
const
scale
=
Math
.
min
(
scaleX
,
scaleY
);
// 保持宽高比
imageElement
.
ref
.
scaleX
=
scale
;
imageElement
.
ref
.
scaleY
=
scale
;
})
// 将图片元素添加到itemNode
fish
.
ref
.
addChild
(
imageElement
.
ref
);
}
if
(
type
==
'
big
'
)
{
fish
.
ref
.
scaleX
=
this
.
g_mapScale
*
1.5
;
fish
.
ref
.
scaleY
=
this
.
g_mapScale
*
1.5
;
}
else
{
fish
.
ref
.
scaleX
=
this
.
g_mapScale
;
fish
.
ref
.
scaleY
=
this
.
g_mapScale
;
}
this
.
render
(
fish
.
ref
,
zIndexMap
.
card
);
return
fish
;
}
...
...
src/app/play/resources.js
View file @
7928d53e
...
...
@@ -12,16 +12,16 @@ const localImages = {
'
fa_yin_an_niu___la_ba
'
:
'
assets/game/fa_yin_an_niu___la_ba.png
'
,
'
guang_shu
'
:
'
assets/game/guang_shu.png
'
,
'
hong_shui_tong
'
:
'
assets/game/hong_shui_tong.png
'
,
'
huang_se_xiao_yu
'
:
'
assets/game/huang_se_xiao_yu.png
'
,
'
huang_se_xiao_yu___dan_ren_mo_shi
'
:
'
assets/game/huang_se_xiao_yu___dan_ren_mo_shi.png
'
,
'
hui_se_mao_pa_zhao
'
:
'
assets/game/hui_se_mao_pa_zhao.png
'
,
'
hui_se_mao_zuo_zhao
'
:
'
assets/game/hui_se_mao_zuo_zhao.png
'
,
'
ju_mao_pa_zhao
'
:
'
assets/game/ju_mao_pa_zhao.png
'
,
'
ju_mao_zuo_zhao
'
:
'
assets/game/ju_mao_zuo_zhao.png
'
,
'
ju_se_xiao_yu
'
:
'
assets/game/ju_se_xiao_yu.png
'
,
'
lan_se_xiao_yu
'
:
'
assets/game/lan_se_xiao_yu.png
'
,
'
lan_se_xiao_yu___dan_ren_mo_shi
'
:
'
assets/game/lan_se_xiao_yu___dan_ren_mo_shi.png
'
,
'
lv_se_xiao_yu
'
:
'
assets/game/lv_se_xiao_yu.png
'
,
'
huang_yu
'
:
'
assets/game/huang_se_xiao_yu.png
'
,
'
huang_yu_da
'
:
'
assets/game/huang_se_xiao_yu___dan_ren_mo_shi.png
'
,
'
ju_yu
'
:
'
assets/game/ju_se_xiao_yu.png
'
,
'
lan_yu
'
:
'
assets/game/lan_se_xiao_yu.png
'
,
'
lan_yu_da
'
:
'
assets/game/lan_se_xiao_yu___dan_ren_mo_shi.png
'
,
'
lv_yu
'
:
'
assets/game/lv_se_xiao_yu.png
'
,
'
pao_pao_da_png
'
:
'
assets/game/pao_pao_da_png.png
'
,
'
shan_guang
'
:
'
assets/game/shan_guang.png
'
,
'
yu_gan
'
:
'
assets/game/yu_gan.png
'
,
...
...
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