Component constructor

Component(
  1. dynamic componentId,
  2. Map<String, dynamic> componentDescription
)

@param {Object} componentId - Id of the component @param {Object} componentDescription - Description of the component to be created

Implementation

Component(dynamic componentId, this.componentDescription) {
  if (componentDescription['visualResponses'] == null
   || componentDescription['gamepadIndices'] == null
   || componentDescription['gamepadIndices'].keys.isEmpty) {
    throw('Invalid arguments supplied');
  }

  id = componentId;
  type = componentDescription['type'];
  rootNodeName = componentDescription['rootNodeName'];
  touchPointNodeName = componentDescription['touchPointNodeName'];

  // Build all the visual responses for this component
  componentDescription['visualResponses'].forEach((responseName,values){
    final visualResponse = VisualResponse(componentDescription['visualResponses'][responseName]);
    visualResponses[responseName] = visualResponse;
  });

  // Set default values
  gamepadIndices = componentDescription['gamepadIndices'];

  values = {
    'state': constants['ComponentState']['DEFAULT'],
    'button': (gamepadIndices['button'] != null) ? 0 : null,
    'xAxis': (gamepadIndices['xAxis'] != null) ? 0 : null,
    'yAxis': (gamepadIndices['yAxis'] != null) ? 0 : null
  };
}