Skip to content

jorbascrumps/phaser-plugin-enhanced-input

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Warning

This plugin is in early development and should be considered experimental. Expect frequent changes, incomplete features, and breaking updates.

Contributions and feedback are welcome, but use in production is not recommended until a stable version is tagged.

Track progress and open issues here: GitHub Issues

Phaser Enhanced Input Plugin

An input plugin for Phaser 3 inspired by Unreal Engine’s Enhanced Input system. Supports mapping keyboard input to named actions, with context-based grouping and optional lifecycle callbacks.

Installation

npm install phaser-plugin-enhanced-input

Usage

Register the plugin

import {EnhancedInputPlugin} from 'phaser-plugin-enhanced-input';

new Phaser.Game({
  // ...
  plugins: {
    scene: [
      {
        key: 'enhancedInput',
        plugin: EnhancedInputPlugin,
        mapping: 'enhancedInput',
      }
    ]
  }
});

Create a context

import {InputMappingContext} from 'phaser-plugin-enhanced-input';

const weaponContext = new InputMappingContext(this, {
    fire: {
        binding: Phaser.Input.Keyboard.KeyCodes.SPACE,
        pressed() {
            console.log('fire pressed');
        },
        held() {
            console.log('fire held');
        },
        released() {
            console.log('fire released');
        },
    },
});
this.enhancedInput.addMappingContext(weaponContext);

Enable or disable input

this.enhancedInput.enableMappingContext(weaponContext);
// Or
weaponContext.enable();

// Later...
this.enhancedInput.disableMappingContext(weaponContext);
// Or
weaponContext.disable();

API

InputMappingContext

  • .enable() – Attach all bindings and begin listening for events
  • .disable() – Detach listeners without destroying state
  • .destroy() – Clean up all resources
  • Access bindings via dot notation: context.fire.pressed(() => ...)

About

An input plugin for Phaser 3 inspired by Unreal Engine’s Enhanced Input system.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published