-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Scott Westover <[email protected]>
- Loading branch information
1 parent
55c1653
commit 02c6e07
Showing
6 changed files
with
118,533 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Phaser 3 - Custom Fonts With Native Phaser!</title> | ||
<style> | ||
html, | ||
body, | ||
.container { | ||
margin: 0px; | ||
height: 100vh; | ||
width: 100vw; | ||
overflow: hidden; | ||
background: #d7d7d7; | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
justify-content: center; | ||
} | ||
</style> | ||
<script src="//cdn.jsdelivr.net/npm/[email protected]/dist/phaser.min.js"></script> | ||
</head> | ||
<body> | ||
<div class="container" id="game-container"></div> | ||
<script type="module" src="src/main.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export default window.Phaser; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import Phaser from './lib/phaser.js'; | ||
|
||
class MainScene extends Phaser.Scene { | ||
constructor() { | ||
super(MainScene.name); | ||
} | ||
|
||
preload() { | ||
this.load.font( | ||
'Kenney-Future-Narrow', | ||
'assets/fonts/Kenney-Future-Narrow.ttf', | ||
'truetype' | ||
); | ||
this.load.font( | ||
'PressStart2P', | ||
'https://raw.githubusercontent.com/google/fonts/refs/heads/main/ofl/pressstart2p/PressStart2P-Regular.ttf', | ||
'truetype' | ||
); | ||
} | ||
|
||
create() { | ||
const w = this.scale.width / 2; | ||
this.add | ||
.text(w, 100, 'Default Font Family', { | ||
fontSize: 40, | ||
color: '#ffffff', | ||
}) | ||
.setOrigin(0.5); | ||
this.add | ||
.text(w, 200, 'Press Start 2P', { | ||
fontSize: 40, | ||
color: '#ffffff', | ||
fontFamily: 'PressStart2P', | ||
}) | ||
.setOrigin(0.5); | ||
this.add | ||
.text(w, 300, 'Kenny Future Narrow', { | ||
fontSize: 40, | ||
color: '#ffffff', | ||
fontFamily: 'Kenney-Future-Narrow', | ||
}) | ||
.setOrigin(0.5); | ||
} | ||
} | ||
|
||
const gameConfig = { | ||
type: Phaser.CANVAS, | ||
pixelArt: true, | ||
scale: { | ||
parent: 'game-container', | ||
width: 800, | ||
height: 480, | ||
}, | ||
backgroundColor: '#5c5b5b', | ||
scene: [MainScene], | ||
}; | ||
|
||
const game = new Phaser.Game(gameConfig); |
Oops, something went wrong.