Getting Started
Installation
Section titled “Installation”Install the package using your preferred package manager:
npm install font-awesome-for-phaserpnpm add font-awesome-for-phaseryarn add font-awesome-for-phaserPrerequisites
Section titled “Prerequisites”Before using Font Awesome for Phaser, make sure you have:
- Phaser 3 installed in your project
- Font Awesome fonts available (either via CDN or self-hosted)
Basic Setup
Section titled “Basic Setup”To use Font Awesome icons in your Phaser game, you need to load the Font Awesome fonts before initializing your game.
Using CDN (Recommended for Quick Start)
Section titled “Using CDN (Recommended for Quick Start)”The simplest way is to use the CDN version:
import { loadFont } from 'font-awesome-for-phaser';import { Game } from 'phaser';import type Phaser from 'phaser';
const config: Phaser.Types.Core.GameConfig = {  type: Phaser.AUTO,  width: 800,  height: 600,  scene: YourScene,};
// Load Font Awesome before starting the gameloadFont().then(() => {  new Game(config);});Using Async/Await
Section titled “Using Async/Await”If you prefer async/await syntax:
async function startGame() {  await loadFont();  new Game(config);}
startGame();TypeScript Configuration
Section titled “TypeScript Configuration”The library is built with TypeScript and includes full type definitions. No additional configuration is needed - just import and use!
import { loadFont, IconText, getIconChar } from 'font-awesome-for-phaser';// All types are automatically availableVerify Installation
Section titled “Verify Installation”Once you’ve set up the library, you can verify it’s working by creating a simple icon in one of your scenes:
import { IconText } from 'font-awesome-for-phaser';
class MyScene extends Phaser.Scene {  create() {    // Create a simple game controller icon    const icon = new IconText(this, 100, 100, 'gamepad', 64, {      color: '#ffffff',      iconStyle: 'solid',    });    this.add.existing(icon);  }}If you see a gamepad icon appear at position (100, 100), you’re all set! 🎉
Next Steps
Section titled “Next Steps”- Learn about Basic Usage patterns
- Explore the IconText Component
- Configure Self-Hosted Fonts for production
- Check the API Reference for all available functions
Troubleshooting
Section titled “Troubleshooting”Icons not appearing?
Section titled “Icons not appearing?”- Make sure loadFont()completes before creating the game
- Check that the font name is wrapped in quotes: font: '36px FontAwesome'(notfont: 36px FontAwesome)
- Verify you’re using the correct icon style for your chosen icon
TypeScript errors?
Section titled “TypeScript errors?”- Ensure you have @types/phaserinstalled
- Update to the latest version of the library
- Check your tsconfig.jsonincludes proper module resolution