generate timer events

beta.r3js.org
-=ybafelo 2018-05-25 12:14:30 +02:00
parent 0094e7a523
commit 31e23e29cf
1 changed files with 29 additions and 10 deletions

View File

@ -75,6 +75,8 @@ this.totalTime = R3.CustomCode.TIME_LIMIT;
this.score = 0;
this.secondCounter = 0;
this.ballY = this.football.instance.geometry.boundingSphere.radius / 2;
if (this.debug) {
@ -90,6 +92,18 @@ R3.CustomCode.prototype.render = function(delta) {
this.totalTime -= delta;
this.secondCounter += delta;
if (this.secondCounter >= 1) {
this.secondCounter -= 1;
R3.Event.Emit(
R3.Event.GAME_DATA,
{
type : 'timer',
time : Math.round(this.totalTime)
}
)
}
if (this.totalTime <= 0) {
this.totalTime = 0;
@ -447,16 +461,11 @@ R3.Event.Subscribe(
}
);
setTimeout(
function() {
R3.Event.Emit(
R3.Event.STOP_AUDIO,
{
name : 'Audio - Crowd'
}
);
},
1500
R3.Event.Emit(
R3.Event.STOP_AUDIO,
{
name : 'Audio - Crowd'
}
);
this.mouseMove.entityLoaded = null;
@ -501,8 +510,18 @@ R3.Event.Subscribe(
this.score = 0;
this.secondCounter = 0;
this.totalTime = R3.CustomCode.TIME_LIMIT;
R3.Event.Emit(
R3.Event.GAME_DATA,
{
type : 'timer',
time : this.totalTime
}
);
this.balls.map(
function(ball) {