Files
esengine/source/src/Utils/Input/Virtual/VirtualIntegerAxis.ts

44 lines
1.3 KiB
TypeScript
Raw Normal View History

2020-08-27 18:48:20 +08:00
module es {
/**
* int(-101)
* 使/
*/
export class VirtualIntegerAxis extends VirtualInput {
public nodes: VirtualAxisNode[] = [];
public get value(){
for (let i = 0; i < this.nodes.length; i ++){
let val = this.nodes[i].value;
if (val != 0)
return Math.sign(val);
}
return 0;
}
constructor(...nodes: VirtualAxisNode[]){
super();
this.nodes.concat(nodes);
}
public update() {
for (let i = 0; i < this.nodes.length; i ++)
this.nodes[i].update();
}
/**
* //
* @param overlapBehavior
* @param negative
* @param positive
*/
public addKeyboardKeys(overlapBehavior: OverlapBehavior, negative: Keys, positive: Keys){
this.nodes.push(new KeyboardKeys(overlapBehavior, negative, positive));
return this;
}
}
export abstract class VirtualAxisNode extends VirtualInputNode {
public abstract value: number;
}
}