pixi.js
    Preparing search index...

    Interface ApplicationPluginAdvanced

    Interface for creating Application plugins. Any plugin that's usable for Application must implement these methods.

    To create a plugin:

    1. Create a class that implements this interface
    2. Add the required static extension property
    3. Register the plugin using extensions.add()
    import { ApplicationPlugin, ExtensionType, extensions } from 'pixi.js';

    class MyPlugin {
    // Required: Declare the extension type
    public static extension = ExtensionType.Application;

    // Required: Implement init method
    public static init(options: Partial<ApplicationOptions>): void {
    // Add properties/methods to the Application instance (this)
    Object.defineProperty(this, 'myFeature', {
    value: () => console.log('My feature!'),
    });

    // Use options if needed
    console.log('Plugin initialized with:', options);
    }

    // Required: Implement destroy method
    public static destroy(): void {
    // Clean up any resources
    console.log('Plugin destroyed');
    }
    }

    // Register the plugin
    extensions.add(MyPlugin);

    // Usage in application
    const app = new Application();
    await app.init();
    app.myFeature(); // Output: "My feature!"
    Important

    • Plugins are initialized in the order they are added
    • Plugins are destroyed in reverse order
    • The this context in both methods refers to the Application instance
    interface ApplicationPlugin {
        destroy(): void;
        init(options: Partial<ApplicationOptions>): void;
    }
    Index

    Methods

    Methods

    • Called when destroying Application, scoped to Application instance.

      Returns void

    • Called when Application is constructed, scoped to Application instance. Passes in options as the only argument, which are Application init() options.

      Parameters

      Returns void