Added animation on coin got

This commit is contained in:
Thomas FORGIONE
2015-07-07 10:19:49 +02:00
parent 24765a4687
commit edffd21eb7
4 changed files with 156 additions and 138 deletions

View File

@@ -89,6 +89,22 @@ Coin.prototype.update = function() {
var self = this;
if (this.ready && this.rotating)
this.mesh.rotation.y += 0.1;
else if (this.got) {
if (this.mesh.material.opacity > 0.02) {
// First update
this.mesh.rotation.y += 0.3;
this.mesh.position.y += 0.05;
this.mesh.material.opacity -= 0.05;
} else {
this.mesh.visible = false;
}
}
};
Coin.prototype.get = function() {
@@ -100,9 +116,12 @@ Coin.prototype.get = function() {
this.callback();
if (this.mesh) {
this.mesh.visible = false;
this.mesh.raycastable = false;
this.mesh.material = this.mesh.material.clone();
this.mesh.material.transparent = true;
this.mesh.material.opacity = 1;
}
Coin.total ++;
Coin.nextSound.play();
if (Coin.total === 9) {

View File

@@ -74,7 +74,6 @@ function init() {
// Initialize pointer camera
camera1 = new L3D.ReplayCamera(50, container_size.width() / container_size.height(), 0.01, 100000, coins);
cameras = initMainScene(camera1, scene, coins);
camera1.cameras = cameras;
// Add listeners
initListeners();