Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
oetzit
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
commul
oetzit
Commits
8f614fcc
Commit
8f614fcc
authored
2 years ago
by
Paolo.Brasolin
Browse files
Options
Downloads
Patches
Plain Diff
feat: #fe parametric input padding for hud
parent
e837a757
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
frontend/src/js/hud.ts
+19
-10
19 additions, 10 deletions
frontend/src/js/hud.ts
with
19 additions
and
10 deletions
frontend/src/js/hud.ts
+
19
−
10
View file @
8f614fcc
...
...
@@ -23,8 +23,9 @@ const INPUT_BASE_TEXT_STYLE = {
interface
HudOptions
{
statsPadding
:
number
;
statsFontSize
:
string
;
inputP
osition
:
number
;
inputP
adding
:
number
;
inputFontSize
:
string
;
inputPosition
:
number
;
}
export
default
class
HUD
{
...
...
@@ -38,10 +39,11 @@ export default class HUD {
constructor
(
scene
:
Phaser
.
Scene
,
options
?:
HudOptions
)
{
this
.
scene
=
scene
;
this
.
options
=
options
||
{
statsPadding
:
Math
.
min
(
this
.
scene
.
cameras
.
main
.
width
*
0.01
,
10
),
// min(1vw,10px)
statsFontSize
:
"
max(3vw,20px)
"
,
// never smaller than 20px
statsPadding
:
10
,
statsFontSize
:
"
22px
"
,
inputPadding
:
4
,
inputFontSize
:
"
60px
"
,
inputPosition
:
0.5
,
inputFontSize
:
"
min(12vw,60px)
"
,
// always fit ~12 chars comfortably in width
};
this
.
input
=
this
.
initInput
(
scene
);
this
.
score
=
this
.
initScore
(
scene
);
...
...
@@ -55,14 +57,22 @@ export default class HUD {
scene
.
cameras
.
main
.
width
/
2
,
scene
.
cameras
.
main
.
height
*
this
.
options
.
inputPosition
,
""
,
{
...
INPUT_BASE_TEXT_STYLE
,
fontSize
:
this
.
options
.
inputFontSize
,
},
this
.
inputTextStyle
(),
)
.
setOrigin
(
0.5
,
0.5
);
}
inputTextStyle
():
Phaser
.
Types
.
GameObjects
.
Text
.
TextStyle
{
return
{
...
INPUT_BASE_TEXT_STYLE
,
fontSize
:
this
.
options
.
inputFontSize
,
padding
:
{
x
:
this
.
options
.
inputPadding
,
y
:
this
.
options
.
inputPadding
,
},
};
}
statsTextStyle
():
Phaser
.
Types
.
GameObjects
.
Text
.
TextStyle
{
return
{
...
STATS_BASE_TEXT_STYLE
,
...
...
@@ -127,8 +137,7 @@ export default class HUD {
this
.
scene
.
cameras
.
main
.
height
*
this
.
options
.
inputPosition
,
input
,
{
...
INPUT_BASE_TEXT_STYLE
,
fontSize
:
this
.
options
.
inputFontSize
,
...
this
.
inputTextStyle
(),
color
:
color
,
},
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment