Controls namespace update

beta.r3js.org
-=yb4f310 2017-12-02 12:01:18 +01:00
parent 503ed91bed
commit 5506d73e56
12 changed files with 275 additions and 275 deletions

View File

@ -478,7 +478,7 @@ GameLib.Component.GetComponentInfo = function(number) {
runtime : GameLib.Component.PHYSICS_RUNTIME runtime : GameLib.Component.PHYSICS_RUNTIME
}; };
case 0x30 : return { case 0x30 : return {
name : 'GameLib.D3.Controls', name : 'GameLib.Controls',
runtime : GameLib.Component.DEFAULT_RUNTIME runtime : GameLib.Component.DEFAULT_RUNTIME
}; };
case 0x31 : return { case 0x31 : return {
@ -486,7 +486,7 @@ GameLib.Component.GetComponentInfo = function(number) {
runtime : GameLib.Component.GRAPHICS_RUNTIME runtime : GameLib.Component.GRAPHICS_RUNTIME
}; };
case 0x32 : return { case 0x32 : return {
name : 'GameLib.D3.Controls.Touch', name : 'GameLib.Controls.Touch',
runtime : GameLib.Component.DEFAULT_RUNTIME runtime : GameLib.Component.DEFAULT_RUNTIME
}; };
case 0x33 : return { case 0x33 : return {
@ -514,11 +514,11 @@ GameLib.Component.GetComponentInfo = function(number) {
runtime : GameLib.Component.DEFAULT_RUNTIME runtime : GameLib.Component.DEFAULT_RUNTIME
}; };
case 0x39 : return { case 0x39 : return {
name : 'GameLib.D3.Controls.Keyboard', name : 'GameLib.Controls.Keyboard',
runtime : GameLib.Component.DEFAULT_RUNTIME runtime : GameLib.Component.DEFAULT_RUNTIME
}; };
case 0x3a : return { case 0x3a : return {
name : 'GameLib.D3.Controls.Mouse', name : 'GameLib.Controls.Mouse',
runtime : GameLib.Component.DEFAULT_RUNTIME runtime : GameLib.Component.DEFAULT_RUNTIME
}; };
case 0x3b : return { case 0x3b : return {

View File

@ -7,7 +7,7 @@
* @param parentEntity * @param parentEntity
* @constructor * @constructor
*/ */
GameLib.D3.API.Controls = function( GameLib.API.Controls = function(
id, id,
controlsType, controlsType,
name, name,
@ -23,19 +23,19 @@ GameLib.D3.API.Controls = function(
if (GameLib.Utils.UndefinedOrNull(controlsType)) { if (GameLib.Utils.UndefinedOrNull(controlsType)) {
if (this instanceof GameLib.D3.Controls.Editor) { if (this instanceof GameLib.D3.Controls.Editor) {
controlsType = GameLib.D3.Controls.CONTROLS_TYPE_EDITOR; controlsType = GameLib.Controls.CONTROLS_TYPE_EDITOR;
} }
if (this instanceof GameLib.D3.Controls.Touch) { if (this instanceof GameLib.Controls.Touch) {
controlsType = GameLib.D3.Controls.CONTROLS_TYPE_TOUCH; controlsType = GameLib.Controls.CONTROLS_TYPE_TOUCH;
} }
if (this instanceof GameLib.D3.Controls.Keyboard) { if (this instanceof GameLib.Controls.Keyboard) {
controlsType = GameLib.D3.Controls.CONTROLS_TYPE_KEYBOARD; controlsType = GameLib.Controls.CONTROLS_TYPE_KEYBOARD;
} }
if (this instanceof GameLib.D3.Controls.Mouse) { if (this instanceof GameLib.Controls.Mouse) {
controlsType = GameLib.D3.Controls.CONTROLS_TYPE_MOUSE; controlsType = GameLib.Controls.CONTROLS_TYPE_MOUSE;
} }
if (GameLib.Utils.UndefinedOrNull(controlsType)) { if (GameLib.Utils.UndefinedOrNull(controlsType)) {
@ -46,19 +46,19 @@ GameLib.D3.API.Controls = function(
if (GameLib.Utils.UndefinedOrNull(name)) { if (GameLib.Utils.UndefinedOrNull(name)) {
if (controlsType === GameLib.D3.Controls.CONTROLS_TYPE_EDITOR) { if (controlsType === GameLib.Controls.CONTROLS_TYPE_EDITOR) {
name = 'Editing Controls'; name = 'Editing Controls';
} }
if (controlsType === GameLib.D3.Controls.CONTROLS_TYPE_TOUCH) { if (controlsType === GameLib.Controls.CONTROLS_TYPE_TOUCH) {
name = 'Touch Controls'; name = 'Touch Controls';
} }
if (controlsType === GameLib.D3.Controls.CONTROLS_TYPE_KEYBOARD) { if (controlsType === GameLib.Controls.CONTROLS_TYPE_KEYBOARD) {
name = 'Keyboard Controls'; name = 'Keyboard Controls';
} }
if (controlsType === GameLib.D3.Controls.CONTROLS_TYPE_MOUSE) { if (controlsType === GameLib.Controls.CONTROLS_TYPE_MOUSE) {
name = 'Mouse Controls'; name = 'Mouse Controls';
} }
@ -82,16 +82,16 @@ GameLib.D3.API.Controls = function(
this.parentEntity = parentEntity; this.parentEntity = parentEntity;
}; };
GameLib.D3.API.Controls.prototype = Object.create(GameLib.Component.prototype); GameLib.API.Controls.prototype = Object.create(GameLib.Component.prototype);
GameLib.D3.API.Controls.prototype.constructor = GameLib.D3.API.Controls; GameLib.API.Controls.prototype.constructor = GameLib.API.Controls;
/** /**
* Returns an API Controls from an Object * Returns an API Controls from an Object
* @param objectControls * @param objectControls
* @constructor * @constructor
*/ */
GameLib.D3.API.Controls.FromObject = function (objectControls){ GameLib.API.Controls.FromObject = function (objectControls){
return new GameLib.D3.API.Controls( return new GameLib.API.Controls(
objectControls.id, objectControls.id,
objectControls.controlsType, objectControls.controlsType,
objectControls.name, objectControls.name,

View File

@ -1,9 +1,9 @@
/** /**
* Controls Superset - The apiControls properties get moved into the Controls object itself, and then the instance is created * Controls Superset - The apiControls properties get moved into the Controls object itself, and then the instance is created
* @param apiControls GameLib.D3.API.Controls * @param apiControls GameLib.API.Controls
* @constructor * @constructor
*/ */
GameLib.D3.Controls = function ( GameLib.Controls = function (
apiControls apiControls
) { ) {
@ -11,11 +11,11 @@ GameLib.D3.Controls = function (
apiControls = {}; apiControls = {};
} }
if (apiControls instanceof GameLib.D3.Controls) { if (apiControls instanceof GameLib.Controls) {
return apiControls; return apiControls;
} }
GameLib.D3.API.Controls.call( GameLib.API.Controls.call(
this, this,
apiControls.id, apiControls.id,
apiControls.controlsType, apiControls.controlsType,
@ -32,7 +32,7 @@ GameLib.D3.Controls = function (
var delayed = false; var delayed = false;
if (this.controlsType === GameLib.D3.Controls.CONTROLS_TYPE_EDITOR) { if (this.controlsType === GameLib.Controls.CONTROLS_TYPE_EDITOR) {
componentType = GameLib.Component.COMPONENT_CONTROLS_EDITOR; componentType = GameLib.Component.COMPONENT_CONTROLS_EDITOR;
@ -42,15 +42,15 @@ GameLib.D3.Controls = function (
delayed = true; delayed = true;
} }
if (this.controlsType === GameLib.D3.Controls.CONTROLS_TYPE_TOUCH) { if (this.controlsType === GameLib.Controls.CONTROLS_TYPE_TOUCH) {
componentType = GameLib.Component.COMPONENT_CONTROLS_TOUCH componentType = GameLib.Component.COMPONENT_CONTROLS_TOUCH
} }
if (this.controlsType === GameLib.D3.Controls.CONTROLS_TYPE_KEYBOARD) { if (this.controlsType === GameLib.Controls.CONTROLS_TYPE_KEYBOARD) {
componentType = GameLib.Component.COMPONENT_CONTROLS_KEYBOARD componentType = GameLib.Component.COMPONENT_CONTROLS_KEYBOARD
} }
if (this.controlsType === GameLib.D3.Controls.CONTROLS_TYPE_MOUSE) { if (this.controlsType === GameLib.Controls.CONTROLS_TYPE_MOUSE) {
componentType = GameLib.Component.COMPONENT_CONTROLS_MOUSE componentType = GameLib.Component.COMPONENT_CONTROLS_MOUSE
} }
@ -62,39 +62,39 @@ GameLib.D3.Controls = function (
); );
}; };
GameLib.D3.Controls.prototype = Object.create(GameLib.D3.API.Controls.prototype); GameLib.Controls.prototype = Object.create(GameLib.API.Controls.prototype);
GameLib.D3.Controls.prototype.constructor = GameLib.D3.Controls; GameLib.Controls.prototype.constructor = GameLib.Controls;
/** /**
* Controls Type * Controls Type
* @type {number} * @type {number}
*/ */
GameLib.D3.Controls.CONTROLS_TYPE_EDITOR = 0x0; GameLib.Controls.CONTROLS_TYPE_EDITOR = 0x0;
GameLib.D3.Controls.CONTROLS_TYPE_TOUCH = 0x1; GameLib.Controls.CONTROLS_TYPE_TOUCH = 0x1;
GameLib.D3.Controls.CONTROLS_TYPE_KEYBOARD = 0x2; GameLib.Controls.CONTROLS_TYPE_KEYBOARD = 0x2;
GameLib.D3.Controls.CONTROLS_TYPE_MOUSE = 0x3; GameLib.Controls.CONTROLS_TYPE_MOUSE = 0x3;
/** /**
* Creates a mesh instance or updates it * Creates a mesh instance or updates it
*/ */
GameLib.D3.Controls.prototype.createInstance = function() { GameLib.Controls.prototype.createInstance = function() {
GameLib.Component.prototype.createInstance.call(this); GameLib.Component.prototype.createInstance.call(this);
}; };
/** /**
* Updates the mesh instance * Updates the mesh instance
*/ */
GameLib.D3.Controls.prototype.updateInstance = function() { GameLib.Controls.prototype.updateInstance = function() {
console.log('default controls update instance'); console.log('default controls update instance');
}; };
/** /**
* Converts a GameLib.D3.Controls to a GameLib.D3.API.Controls * Converts a GameLib.Controls to a GameLib.API.Controls
* @returns {GameLib.D3.API.Controls} * @returns {GameLib.API.Controls}
*/ */
GameLib.D3.Controls.prototype.toApiObject = function() { GameLib.Controls.prototype.toApiObject = function() {
var apiControls = new GameLib.D3.API.Controls( var apiControls = new GameLib.API.Controls(
this.id, this.id,
this.controlsType, this.controlsType,
this.name, this.name,
@ -106,15 +106,15 @@ GameLib.D3.Controls.prototype.toApiObject = function() {
}; };
/** /**
* Converts a data object to a GameLib.D3.Controls * Converts a data object to a GameLib.Controls
* @param objectControls {Object} * @param objectControls {Object}
* @constructor * @constructor
*/ */
GameLib.D3.Controls.FromObject = function(objectControls) { GameLib.Controls.FromObject = function(objectControls) {
var apiControls = GameLib.D3.API.Controls.FromObject(objectControls); var apiControls = GameLib.API.Controls.FromObject(objectControls);
return new GameLib.D3.Controls( return new GameLib.Controls(
apiControls apiControls
); );

View File

@ -0,0 +1,67 @@
/**
* Keyboard Controls
* @param apiControls GameLib.API.Controls
* @constructor
*/
GameLib.Controls.Keyboard = function (
apiControls
) {
GameLib.Controls.call(
this,
apiControls
);
};
/**
* Inheritance
* @type {GameLib.Controls}
*/
GameLib.Controls.Keyboard.prototype = Object.create(GameLib.Controls.prototype);
GameLib.Controls.Keyboard.prototype.constructor = GameLib.Controls.Keyboard;
/**
* Create Instance
* @returns
*/
GameLib.Controls.Keyboard.prototype.createInstance = function() {
/**
* Set instance to true to indicate no dependencies to other components
*/
this.instance = true;
GameLib.Controls.prototype.createInstance.call(this);
};
/**
* Update Instance
*/
GameLib.Controls.Keyboard.prototype.updateInstance = function() {
GameLib.Controls.prototype.updateInstance.call(this);
};
/**
* Converts a GameLib.Controls.Keyboard to a GameLib.API.Controls
* @returns {GameLib.API.Controls}
*/
GameLib.Controls.Keyboard.prototype.toApiObject = function() {
var apiControls = GameLib.Controls.prototype.toApiObject.call(this);
/**
* add other properties here as this component develops...
*/
return apiControls;
};
/**
* Construct an Keyboard Controls object from data
* @param objectControls
* @returns {GameLib.Controls.Keyboard}
* @constructor
*/
GameLib.Controls.Keyboard.FromObject = function(objectControls) {
var apiControls = GameLib.API.Controls.FromObject(objectControls);
return new GameLib.Controls.Keyboard(
apiControls
);
};

View File

@ -0,0 +1,67 @@
/**
* Mouse Controls
* @param apiControls GameLib.API.Controls
* @constructor
*/
GameLib.Controls.Mouse = function (
apiControls
) {
GameLib.Controls.call(
this,
apiControls
);
};
/**
* Inheritance
* @type {GameLib.Controls}
*/
GameLib.Controls.Mouse.prototype = Object.create(GameLib.Controls.prototype);
GameLib.Controls.Mouse.prototype.constructor = GameLib.Controls.Mouse;
/**
* Create Instance
* @returns
*/
GameLib.Controls.Mouse.prototype.createInstance = function() {
/**
* Set instance to true to indicate no dependencies to other components
*/
this.instance = true;
GameLib.Controls.prototype.createInstance.call(this);
};
/**
* Update Instance
*/
GameLib.Controls.Mouse.prototype.updateInstance = function() {
GameLib.Controls.prototype.updateInstance.call(this);
};
/**
* Converts a GameLib.Controls.Mouse to a GameLib.API.Controls
* @returns {GameLib.API.Controls}
*/
GameLib.Controls.Mouse.prototype.toApiObject = function() {
var apiControls = GameLib.Controls.prototype.toApiObject.call(this);
/**
* add other properties here as this component develops...
*/
return apiControls;
};
/**
* Construct an Mouse Controls object from data
* @param objectControls
* @returns {GameLib.Controls.Mouse}
* @constructor
*/
GameLib.Controls.Mouse.FromObject = function(objectControls) {
var apiControls = GameLib.API.Controls.FromObject(objectControls);
return new GameLib.Controls.Mouse(
apiControls
);
};

View File

@ -0,0 +1,79 @@
/**
* Touch Controls
* @param apiControls GameLib.API.Controls
* @param sensitivity
* @constructor
*/
GameLib.Controls.Touch = function (
apiControls,
sensitivity
) {
if (GameLib.Utils.UndefinedOrNull(sensitivity)) {
sensitivity = 5;
}
this.sensitivity = sensitivity;
GameLib.Controls.call(
this,
apiControls
);
};
/**
* Inheritance
* @type {GameLib.Controls}
*/
GameLib.Controls.Touch.prototype = Object.create(GameLib.Controls.prototype);
GameLib.Controls.Touch.prototype.constructor = GameLib.Controls.Touch;
/**
* Create Instance
* @returns
*/
GameLib.Controls.Touch.prototype.createInstance = function() {
/**
* Set instance to true to indicate no dependencies to other components
*/
this.instance = true;
GameLib.Controls.prototype.createInstance.call(this);
};
/**
* Update Instance
*/
GameLib.Controls.Touch.prototype.updateInstance = function() {
GameLib.Controls.prototype.updateInstance.call(this);
};
/**
* Converts a GameLib.Controls.Touch to a GameLib.API.Controls
* @returns {GameLib.API.Controls}
*/
GameLib.Controls.Touch.prototype.toApiObject = function() {
var apiControls = GameLib.Controls.prototype.toApiObject.call(this);
apiControls.sensitivity = this.sensitivity;
/**
* add other properties here as this component develops...
*/
return apiControls;
};
/**
* Construct an Touch Controls object from data
* @param objectControls
* @returns {GameLib.Controls.Touch}
* @constructor
*/
GameLib.Controls.Touch.FromObject = function(objectControls) {
var apiControls = GameLib.API.Controls.FromObject(objectControls);
return new GameLib.Controls.Touch(
apiControls,
objectControls.sensitivity
);
};

View File

@ -1,7 +1,7 @@
/** /**
* Controls Superset - The apiControls properties get moved into the Controls object itself, and then the instance is created * Controls Superset - The apiControls properties get moved into the Controls object itself, and then the instance is created
* @param graphics GameLib.GraphicsRuntime * @param graphics GameLib.GraphicsRuntime
* @param apiControls GameLib.D3.API.Controls * @param apiControls GameLib.API.Controls
* @param raycaster * @param raycaster
* @param camera * @param camera
* @constructor * @constructor
@ -40,7 +40,7 @@ GameLib.D3.Controls.Editor = function (
) )
} }
GameLib.D3.Controls.call( GameLib.Controls.call(
this, this,
apiControls apiControls
); );
@ -48,9 +48,9 @@ GameLib.D3.Controls.Editor = function (
/** /**
* Inheritance * Inheritance
* @type {GameLib.D3.Controls} * @type {GameLib.Controls}
*/ */
GameLib.D3.Controls.Editor.prototype = Object.create(GameLib.D3.Controls.prototype); GameLib.D3.Controls.Editor.prototype = Object.create(GameLib.Controls.prototype);
GameLib.D3.Controls.Editor.prototype.constructor = GameLib.D3.Controls.Editor; GameLib.D3.Controls.Editor.prototype.constructor = GameLib.D3.Controls.Editor;
/** /**
@ -72,7 +72,7 @@ GameLib.D3.Controls.Editor.prototype.createInstance = function() {
this.domElement.instance this.domElement.instance
); );
GameLib.D3.Controls.prototype.createInstance.call(this); GameLib.Controls.prototype.createInstance.call(this);
}; };
/** /**
@ -82,16 +82,16 @@ GameLib.D3.Controls.Editor.prototype.updateInstance = function() {
console.warn('an update instance was called on editor controls - which, if not called from within a running system at the right time will affect the order of input event handling and cause system instability'); console.warn('an update instance was called on editor controls - which, if not called from within a running system at the right time will affect the order of input event handling and cause system instability');
GameLib.D3.Controls.prototype.updateInstance.call(this); GameLib.Controls.prototype.updateInstance.call(this);
}; };
/** /**
* Converts a GameLib.D3.Controls.Editor to a GameLib.D3.API.Mesh * Converts a GameLib.D3.Controls.Editor to a GameLib.D3.API.Mesh
* @returns {GameLib.D3.API.Controls} * @returns {GameLib.API.Controls}
*/ */
GameLib.D3.Controls.Editor.prototype.toApiObject = function() { GameLib.D3.Controls.Editor.prototype.toApiObject = function() {
var apiControls = GameLib.D3.Controls.prototype.toApiObject.call(this); var apiControls = GameLib.Controls.prototype.toApiObject.call(this);
apiControls.raycaster = GameLib.Utils.IdOrNull(this.raycaster); apiControls.raycaster = GameLib.Utils.IdOrNull(this.raycaster);
apiControls.camera = GameLib.Utils.IdOrNull(this.camera); apiControls.camera = GameLib.Utils.IdOrNull(this.camera);
@ -108,7 +108,7 @@ GameLib.D3.Controls.Editor.prototype.toApiObject = function() {
*/ */
GameLib.D3.Controls.Editor.FromObject = function(graphics, objectControls) { GameLib.D3.Controls.Editor.FromObject = function(graphics, objectControls) {
var apiControls = GameLib.D3.API.Controls.FromObject(objectControls); var apiControls = GameLib.API.Controls.FromObject(objectControls);
return new GameLib.D3.Controls.Editor( return new GameLib.D3.Controls.Editor(
graphics, graphics,

View File

@ -1,67 +0,0 @@
/**
* Keyboard Controls
* @param apiControls GameLib.D3.API.Controls
* @constructor
*/
GameLib.D3.Controls.Keyboard = function (
apiControls
) {
GameLib.D3.Controls.call(
this,
apiControls
);
};
/**
* Inheritance
* @type {GameLib.D3.Controls}
*/
GameLib.D3.Controls.Keyboard.prototype = Object.create(GameLib.D3.Controls.prototype);
GameLib.D3.Controls.Keyboard.prototype.constructor = GameLib.D3.Controls.Keyboard;
/**
* Create Instance
* @returns
*/
GameLib.D3.Controls.Keyboard.prototype.createInstance = function() {
/**
* Set instance to true to indicate no dependencies to other components
*/
this.instance = true;
GameLib.D3.Controls.prototype.createInstance.call(this);
};
/**
* Update Instance
*/
GameLib.D3.Controls.Keyboard.prototype.updateInstance = function() {
GameLib.D3.Controls.prototype.updateInstance.call(this);
};
/**
* Converts a GameLib.D3.Controls.Keyboard to a GameLib.D3.API.Controls
* @returns {GameLib.D3.API.Controls}
*/
GameLib.D3.Controls.Keyboard.prototype.toApiObject = function() {
var apiControls = GameLib.D3.Controls.prototype.toApiObject.call(this);
/**
* add other properties here as this component develops...
*/
return apiControls;
};
/**
* Construct an Keyboard Controls object from data
* @param objectControls
* @returns {GameLib.D3.Controls.Keyboard}
* @constructor
*/
GameLib.D3.Controls.Keyboard.FromObject = function(objectControls) {
var apiControls = GameLib.D3.API.Controls.FromObject(objectControls);
return new GameLib.D3.Controls.Keyboard(
apiControls
);
};

View File

@ -1,67 +0,0 @@
/**
* Mouse Controls
* @param apiControls GameLib.D3.API.Controls
* @constructor
*/
GameLib.D3.Controls.Mouse = function (
apiControls
) {
GameLib.D3.Controls.call(
this,
apiControls
);
};
/**
* Inheritance
* @type {GameLib.D3.Controls}
*/
GameLib.D3.Controls.Mouse.prototype = Object.create(GameLib.D3.Controls.prototype);
GameLib.D3.Controls.Mouse.prototype.constructor = GameLib.D3.Controls.Mouse;
/**
* Create Instance
* @returns
*/
GameLib.D3.Controls.Mouse.prototype.createInstance = function() {
/**
* Set instance to true to indicate no dependencies to other components
*/
this.instance = true;
GameLib.D3.Controls.prototype.createInstance.call(this);
};
/**
* Update Instance
*/
GameLib.D3.Controls.Mouse.prototype.updateInstance = function() {
GameLib.D3.Controls.prototype.updateInstance.call(this);
};
/**
* Converts a GameLib.D3.Controls.Mouse to a GameLib.D3.API.Controls
* @returns {GameLib.D3.API.Controls}
*/
GameLib.D3.Controls.Mouse.prototype.toApiObject = function() {
var apiControls = GameLib.D3.Controls.prototype.toApiObject.call(this);
/**
* add other properties here as this component develops...
*/
return apiControls;
};
/**
* Construct an Mouse Controls object from data
* @param objectControls
* @returns {GameLib.D3.Controls.Mouse}
* @constructor
*/
GameLib.D3.Controls.Mouse.FromObject = function(objectControls) {
var apiControls = GameLib.D3.API.Controls.FromObject(objectControls);
return new GameLib.D3.Controls.Mouse(
apiControls
);
};

View File

@ -1,79 +0,0 @@
/**
* Touch Controls
* @param apiControls GameLib.D3.API.Controls
* @param sensitivity
* @constructor
*/
GameLib.D3.Controls.Touch = function (
apiControls,
sensitivity
) {
if (GameLib.Utils.UndefinedOrNull(sensitivity)) {
sensitivity = 5;
}
this.sensitivity = sensitivity;
GameLib.D3.Controls.call(
this,
apiControls
);
};
/**
* Inheritance
* @type {GameLib.D3.Controls}
*/
GameLib.D3.Controls.Touch.prototype = Object.create(GameLib.D3.Controls.prototype);
GameLib.D3.Controls.Touch.prototype.constructor = GameLib.D3.Controls.Touch;
/**
* Create Instance
* @returns
*/
GameLib.D3.Controls.Touch.prototype.createInstance = function() {
/**
* Set instance to true to indicate no dependencies to other components
*/
this.instance = true;
GameLib.D3.Controls.prototype.createInstance.call(this);
};
/**
* Update Instance
*/
GameLib.D3.Controls.Touch.prototype.updateInstance = function() {
GameLib.D3.Controls.prototype.updateInstance.call(this);
};
/**
* Converts a GameLib.D3.Controls.Touch to a GameLib.D3.API.Controls
* @returns {GameLib.D3.API.Controls}
*/
GameLib.D3.Controls.Touch.prototype.toApiObject = function() {
var apiControls = GameLib.D3.Controls.prototype.toApiObject.call(this);
apiControls.sensitivity = this.sensitivity;
/**
* add other properties here as this component develops...
*/
return apiControls;
};
/**
* Construct an Touch Controls object from data
* @param objectControls
* @returns {GameLib.D3.Controls.Touch}
* @constructor
*/
GameLib.D3.Controls.Touch.FromObject = function(objectControls) {
var apiControls = GameLib.D3.API.Controls.FromObject(objectControls);
return new GameLib.D3.Controls.Touch(
apiControls,
objectControls.sensitivity
);
};

View File

@ -45,9 +45,9 @@ GameLib.System = function(
if (apiSystem.systemType === GameLib.System.SYSTEM_TYPE_INPUT) { if (apiSystem.systemType === GameLib.System.SYSTEM_TYPE_INPUT) {
componentType = GameLib.Component.COMPONENT_SYSTEM_INPUT; componentType = GameLib.Component.COMPONENT_SYSTEM_INPUT;
linkedObjects.mouseControls = [GameLib.D3.Controls.Mouse]; linkedObjects.mouseControls = [GameLib.Controls.Mouse];
linkedObjects.keyboardControls = [GameLib.D3.Controls.Keyboard]; linkedObjects.keyboardControls = [GameLib.Controls.Keyboard];
linkedObjects.touchControls = [GameLib.D3.Controls.Touch]; linkedObjects.touchControls = [GameLib.Controls.Touch];
linkedObjects.editorControls = [GameLib.D3.Controls.Editor]; linkedObjects.editorControls = [GameLib.D3.Controls.Editor];
} }

View File

@ -77,11 +77,11 @@ GameLib.System.Input.prototype.start = function() {
this.editorControls = GameLib.EntityManager.Instance.queryComponents(GameLib.D3.Controls.Editor); this.editorControls = GameLib.EntityManager.Instance.queryComponents(GameLib.D3.Controls.Editor);
this.touchControls = GameLib.EntityManager.Instance.queryComponents(GameLib.D3.Controls.Touch); this.touchControls = GameLib.EntityManager.Instance.queryComponents(GameLib.Controls.Touch);
this.keyboardControls = GameLib.EntityManager.Instance.queryComponents(GameLib.D3.Controls.Keyboard); this.keyboardControls = GameLib.EntityManager.Instance.queryComponents(GameLib.Controls.Keyboard);
this.mouseControls = GameLib.EntityManager.Instance.queryComponents(GameLib.D3.Controls.Mouse); this.mouseControls = GameLib.EntityManager.Instance.queryComponents(GameLib.Controls.Mouse);
this.instanceCreatedSubscription = GameLib.Event.Subscribe( this.instanceCreatedSubscription = GameLib.Event.Subscribe(
GameLib.Event.INSTANCE_CREATED, GameLib.Event.INSTANCE_CREATED,
@ -157,7 +157,7 @@ GameLib.System.Input.prototype.instanceCreated = function(data) {
} }
} }
if (data.component instanceof GameLib.D3.Controls.Touch) { if (data.component instanceof GameLib.Controls.Touch) {
if (this.touchControls.length > 0) { if (this.touchControls.length > 0) {
console.log('ignoring multiple touch controls') console.log('ignoring multiple touch controls')
} else { } else {
@ -166,7 +166,7 @@ GameLib.System.Input.prototype.instanceCreated = function(data) {
} }
} }
if (data.component instanceof GameLib.D3.Controls.Keyboard) { if (data.component instanceof GameLib.Controls.Keyboard) {
if (this.keyboardControls.length > 0) { if (this.keyboardControls.length > 0) {
console.log('ignoring multiple keyboard controls') console.log('ignoring multiple keyboard controls')
} else { } else {
@ -175,7 +175,7 @@ GameLib.System.Input.prototype.instanceCreated = function(data) {
} }
} }
if (data.component instanceof GameLib.D3.Controls.Mouse) { if (data.component instanceof GameLib.Controls.Mouse) {
if (this.mouseControls.length > 0) { if (this.mouseControls.length > 0) {
console.log('ignoring multiple mouse controls') console.log('ignoring multiple mouse controls')
} else { } else {