From 454b3b9516ee689c446b02511c58607dfadaf368 Mon Sep 17 00:00:00 2001 From: Gregg Tavares Date: Sun, 8 Jun 2014 15:46:53 +0900 Subject: [PATCH] update unity docs to show controller example --- docs/unitydocs.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/unitydocs.md b/docs/unitydocs.md index 01565505..5f7a3883 100644 --- a/docs/unitydocs.md +++ b/docs/unitydocs.md @@ -112,6 +112,14 @@ To send one call NetPlayer.sendCmd The smartphone's client will receive a 'scored' command with the data. eg. {points: 7} + // On the phone + var someFunctionToHandleScoring = function(data) { + console.log("You scored " + data.points + " points!"); + }; + + gameclient.addEventListener('scored', someFunctionToHandleScoring); + + You also need to handle if the player's smartphone disconnects. You do this by adding an OnDisconnect event handler.