Added red coin counter

This commit is contained in:
Thomas FORGIONE 2015-06-05 15:47:36 +02:00
parent 1923a20f19
commit 855a8ef590
3 changed files with 37 additions and 0 deletions

35
js/prototype/Coin.js vendored
View File

@ -11,6 +11,39 @@ var Coin = function(x,y,z, callback) {
var _toto = new Audio();
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.top = "0px";
Coin.domElement.style.right = "0px";
Coin.image = new Image();
Coin.image.src = '/static/img/redcoin.png';
Coin.update = function() {
console.log("ok");
Coin.domElement.width = Coin.domElement.width;
Coin.ctx.drawImage(Coin.image,200,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.fill();
Coin.ctx.stroke();
}
Coin.image.onload = Coin.update;
Coin.total = 1;
Coin.ctx = Coin.domElement.getContext('2d');
Coin.update();
Coin.prototype.init = function(x,y,z) {
if (Coin.BASIC_MESH !== null) {
this.mesh = Coin.BASIC_MESH.clone();
@ -70,6 +103,8 @@ Coin.prototype.get = function() {
Coin.nextSound = new Audio('/static/data/music/redcoins/' + Coin.total + Coin.extension);
Coin.nextSound.preload = "auto";
}
Coin.update();
}
}

View File

@ -74,10 +74,12 @@ function init() {
container.appendChild( stats.domElement );
container.appendChild(previewer.domElement);
container.appendChild(renderer.domElement);
container.appendChild(Coin.domElement);
// Initialize pointer camera
var camera1 = new PointerCamera(50, container_size.width() / container_size.height(), 0.1, 100000, renderer, container);
BD.disable();
cameras = initMainScene(camera1, scene, static_path, coins);
// cameras = initPeach(camera1, scene, static_path, coins);
// cameras = initBobomb(camera1, scene, static_path, coins);

BIN
static/img/redcoin.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB