Factory.getForType()
Type | function |
Library | wattageTileEngine.ObjectSystem.Factory.* |
Return value | function |
Keywords | |
See also |
Overview
This function returns the registered constructor for the specified type.
NOTE: This function is used internally by the object system.
Syntax
Factory.getForType( typeName, factoryMethod )
typeName (required)
String. Name of the type.
Examples
local TileEngine = require 'plugin.wattageTileEngine'
local Object = TileEngine.ObjectSystem.Object
local ObjectFactory = TileEngine.ObjectSystem.Factory
local AnimalClass = {}
AnimalClass.new = function(nameParam)
local self = Object.new({objectType="Animal"})
local name = nameParam
function self.sayName()
print("Hello, my name is " .. name)
end
return self
end
ObjectFactory.registerForType("Animal", AnimalClass.new)
local animalNamedFred = ObjectFactory.getForType("Animal")("Fred")