Player Outputs

Outputs

name touch count description
edge 2 moves an edge with two circles for each finger.
disc 1 moves a disc when touching using one finger.
swipe 1 tracks touch movements which are translated to up/down/left/right events.
touch 1 send touch events for one finger only. No draw feedback.

edge

The edge output motion requires two touches. If the player sends two touch events then the game will show 2 circles connected with an edge. The edge sprite will have physical properties such that it can be used to apply forces to other physical sprites. See edge properties

Example

UB.player(playerID).enableOutput("edge");

disc

The disc output motion requires a single touch. If the player send one touch event then the game will show 1 circle sprite, the disc. The disc sprite will have physical properties such that it can be used to apply forces to other physical sprites. See disc properties

Example

UB.player(playerID).enableOutput("disc");

swipe

The swipe output motion requires a single touch. A gesture by the player is translated into one of the swipe events. Event names are:

In your script, you can enable, listen to and handle the swipeUp the event:

UB.player(playerID).enableOutput("swipe");
function handleSwipeUp(event) {
	console.log(event.data.playerID);
}
UB.game.on("swipeUp", handleSwipeUp);

Example event:

{"name":"swipeUp", 
"data": 
	{"playerID":1
	,"dx":-59
	,"dy":-74}
}

The dx and dy values indicate the displacement of the touch between the start and the end of the motion.

touch

The touch output motion requires a single touch. Every state change produces it own event. Event names are:

In your script, you can enable, listen to and handle the touchMoved the event:

UB.player(playerID).enableOutput("touch");	
function handleTouchMove(event) {
	console.log(event.data.playerID);
}	
UB.game.on("touchMove", handleTouchMove);

Example event:

{"name":"touchMove", 
"data": 
	{"playerID":1
	,"x":455
	,"y":483}
}