@moxijs/core - v0.3.4
    Preparing search index...

    Function asEntity

    • Convert a PIXI.Container to an entity with logic support. This is the main way to add Moxi functionality to PIXI objects.

      Type Parameters

      • T extends Container<ContainerChild>

      Parameters

      • entity: T

        Any PIXI.Container (Sprite, Graphics, Container, etc.)

      • logic: MoxiLogic<T> = {}

        Optional initial logic components to attach

      Returns AsEntity<T>

      The same entity with moxiEntity property attached

      const player = asEntity(new PIXI.Sprite(texture));
      player.moxiEntity.addLogic(new PlayerController());
      scene.addChild(player);

      // With initial logic
      const enemy = asEntity(new PIXI.Sprite(texture), {
      'EnemyAI': new EnemyAI()
      });