Corrected coin counter

Clicking on it will work when trying to click on a red coin or arrow
This commit is contained in:
Thomas FORGIONE 2015-06-05 17:15:59 +02:00
parent ab1d655442
commit 01f7fabd6c
3 changed files with 28 additions and 8 deletions

30
js/prototype/Coin.js vendored
View File

@ -13,24 +13,44 @@ Coin.extension = _toto.canPlayType("audio/x-vorbis") === "" ? ".ogg" : ".mp3";
Coin.domElement = document.createElement('canvas');
Coin.domElement.style.position = 'absolute';
// Coin.domElement.style.cssFloat = 'top-right';
Coin.domElement.style.cssFloat = 'top-left';
Coin.domElement.style.top = "0px";
Coin.domElement.style.right = "0px";
Coin.domElement.style.left = "0px";
Coin.image = new Image();
Coin.image.src = '/static/img/redcoin.png';
Coin.initSize = function() {
try {
Coin.domElement.width = container_size.width();
Coin.domElement.height = container_size.height();
} catch (e) {
setTimeout(100, Coin.initSize);
return;
}
}
Coin.update = function() {
var x;
try {
x = container_size.width() * 4.25 / 5;
Coin.domElement.width = container_size.width();
Coin.domElement.height = container_size.height();
} catch (e) {
return;
}
Coin.domElement.width = Coin.domElement.width;
Coin.ctx.drawImage(Coin.image,200,25,30,30);
Coin.ctx.drawImage(Coin.image, x + 75,25,30,30);
Coin.ctx.fillStyle = 'red';
Coin.ctx.strokeStyle = 'black';
Coin.ctx.font = "30px Verdana";
Coin.ctx.fillText(Coin.total - 1 + " / " + 8, 125, 50);
Coin.ctx.strokeText(Coin.total - 1 + " / " + 8, 125, 50);
Coin.ctx.fillText(Coin.total - 1 + " / " + 8, x, 50);
Coin.ctx.strokeText(Coin.total - 1 + " / " + 8, x, 50);
Coin.ctx.fill();
Coin.ctx.stroke();

View File

@ -73,8 +73,8 @@ function init() {
// Add elements to page
container.appendChild( stats.domElement );
container.appendChild(previewer.domElement);
container.appendChild(renderer.domElement);
container.appendChild(Coin.domElement);
container.appendChild(renderer.domElement);
// Initialize pointer camera
var camera1 = new PointerCamera(50, container_size.width() / container_size.height(), 0.1, 100000, renderer, container);

View File

@ -64,7 +64,7 @@ CameraSelecter.prototype.update = function(event) {
}
var previousCamera = this.currentPointedCamera;
var hovered = this.pointedCamera(event);
var hovered = this.pointedCamera();
if (hovered !== undefined && !(hovered instanceof Coin)) {
if (hovered !== previousCamera) {
@ -92,7 +92,7 @@ CameraSelecter.prototype.update = function(event) {
}
CameraSelecter.prototype.click = function(event) {
var newCamera = this.pointedCamera(event);
var newCamera = this.pointedCamera();
if (newCamera !== undefined && !(newCamera instanceof Coin)) {
var event = new BD.Event.ArrowClicked();
event.arrow_id = this.cameras.cameras.indexOf(newCamera);