melonJS
    Preparing search index...

    Function registerTiledObjectClass

    • Register a class constructor as a Tiled object factory. When an object with a matching class or name is found in a Tiled map, an instance of the given constructor will be created with new Constructor(x, y, settings).

      This is a convenience wrapper around registerTiledObjectFactory. If the same class is registered twice with the same constructor, the call is silently ignored. If a different constructor is registered for the same name, an error is thrown.

      Note: classes registered via pool.register are also automatically registered as Tiled object factories (unless pool.autoRegisterTiled is set to false).

      Parameters

      • name: string

        the Tiled class or object name to match

      • Constructor: Function

        class constructor with signature (x, y, settings)

      Returns void

      // register a custom enemy class for use in Tiled maps
      // In Tiled: set the object class to "Enemy" and add custom properties
      registerTiledObjectClass("Enemy", Enemy);
      // equivalent to pool.register (which auto-registers for Tiled too)
      pool.register("CoinEntity", CoinEntity, true);
      // CoinEntity is now available both in the pool AND as a Tiled object factory