-
Notifications
You must be signed in to change notification settings - Fork 0
Controllers
Use one of following controllers.
- OneButton
- TwoButtons
- TwoActionButtons
- FourButtons
- FiveButtons
- SixButtons
- FourArrows
- Touch
- Joystick
- JoystickWithButton
- TwoArrowsTwoButtons
- TwoArrowsOneButton
Controller with only one button. Binded to spacebar on web.
Controller with two buttons. Binded to left and right arrow on web.
Controller with two action buttons (A,B). Binded to left and right arrow on web.
Controller with two arrows and one action button
Controller with four arrow buttons. Binded to arrows on web.
Controller with four buttons. Binded to up, left and right arrow and spacebar on web.
Controller with five buttons. Binded to arrows and spacebar on web.
Controller with six buttons. Binded to arrows, spacebar and ctrl on web.
This controller has no buttons. Instead it has a touchpad which triggers touchstart, touchend, touchmove, touchcancel, touchend events (similar to Touch event types)
The position of the touch is in the data.position
argument as a x and y with the values between [0, 0] for the left top corner and [1, 1] for the bottom right corner ([0.5, 0.5] is the center).
gamee.gameInit("Touch", {}, capabilities, function(error, data) {
if(error !== null)
throw error;
var myController = data.controller;
myController.on('touchstart', function(data) {
if (data.position.x < 0.5 && data.position.y < 0.5) {
console.log('touch in the top left quadrant');
}
});
... // your code that should make game ready
});
JoystickController emits change
event, after the position of the joystick is changed.
The position of the joystick is in the property x
and y
. The position on axis is between <-1, 1> (for x -1 is max left position, 1 max right position). [0.0, 0.0] is the center.
gamee.gameInit("Joystick", {}, capabilities, function(error, data) {
if(error !== null)
throw error;
var myController = data.controller;
myController.on('touchstart', function(data) {
myController.on('change', function() {
new_x = myController.x;
nex_y = myController.y;
});
... // your code that should make game ready
});
JoystickButtonController is a JoystickController
with one button.
gamee.gameInit("JoystickWithButton", {}, capabilities, function(error, data) {
if(error !== null)
throw error;
var myController = data.controller;
myController.on('touchstart', function(data) {
myController.on('change', function() {
new_x = myController.x;
nex_y = myController.y;
});
joystickmyController.on('keydown', callback)
... // your code that should make game ready
});