Cleaning and coin events
This commit is contained in:
@@ -1,19 +1,26 @@
|
||||
var BD = {};
|
||||
|
||||
BD.Private = {};
|
||||
BD.Private.sendData = function(url, data) {
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("POST", url, true);
|
||||
xhr.setRequestHeader("Content-type", "application/json;charset=UTF-8");
|
||||
xhr.send(JSON.stringify(data));
|
||||
}
|
||||
|
||||
BD.Event = {};
|
||||
|
||||
BD.Event.ArrowClicked = function() {};
|
||||
BD.Event.ArrowClicked.prototype.send = function() {
|
||||
var url = "/post";
|
||||
var url = "/arrow-clicked";
|
||||
var data = {arrow_id: this.arrow_id};
|
||||
BD.Private.sendData(url, data);
|
||||
}
|
||||
|
||||
var data = {};
|
||||
|
||||
data.arrow_id = this.arrow_id;
|
||||
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("POST", url, true);
|
||||
xhr.setRequestHeader("Content-type", "application/json;charset=UTF-8");
|
||||
xhr.send(JSON.stringify(data));
|
||||
|
||||
};
|
||||
BD.Event.CoinClicked = function() {};
|
||||
BD.Event.CoinClicked.prototype.send = function() {
|
||||
var url = "/coin-clicked";
|
||||
var data = {coin_id: this.coin_id};
|
||||
BD.Private.sendData(url, data);
|
||||
}
|
||||
|
||||
|
||||
5
static/js/prototype/raycasterTools.js
vendored
5
static/js/prototype/raycasterTools.js
vendored
@@ -77,12 +77,15 @@ CameraSelecter.prototype.click = function(event) {
|
||||
if (newCamera !== undefined && !(newCamera instanceof Coin)) {
|
||||
var event = new BD.Event.ArrowClicked();
|
||||
event.arrow_id = cameras.cameras.indexOf(newCamera);
|
||||
event.user_id = 1;
|
||||
event.send();
|
||||
|
||||
this.cameras.mainCamera().moveHermite(newCamera);
|
||||
buttonManager.updateElements();
|
||||
} else if (newCamera instanceof Coin) {
|
||||
// Coin found, notify server
|
||||
var event = new BD.Event.CoinClicked();
|
||||
event.coin_id = coins.indexOf(newCamera);
|
||||
event.send();
|
||||
newCamera.get();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user