PrincipalGame.Presentation = function(game){

}

PrincipalGame.Presentation.prototype = {
	init: function(){

	},

	preload: function(){

	},

	create: function(){
		this.slides = [];
		this.currentslide = 0;
		this.elapsedTime = 0;
		this.maxTime = 3000;

		this.slides.push( this.game.add.sprite(0, 0, 'presentacion0') );
		this.slides.push( this.game.add.sprite(0, 0, 'presentacion1') );
		this.slides.push( this.game.add.sprite(0, 0, 'presentacion2') );

		this.slides.forEach(function(s, i){
		    s.alpha = (i==0)?1:0;
		});
	},

	update:function(){
		var self = this;

		//self.game.state.start('Main');
		//return;

		self.elapsedTime += this.game.time.elapsed;

		if(self.elapsedTime >= self.maxTime){
		    self.elapsedTime=0;
		    self.currentslide++;

		    if( self.currentslide>= self.slides.length){
			setTimeout(function(){
				INTRO_MUSIC.stop();
			    self.game.state.start('Main');
			}, self.elapsedTime );
		    }
		    else {

			self.game.add.tween( self.slides[self.currentslide-1] )
			    .to({alpha: 0},
			    1500,
			    Phaser.Easing.Linear.None,
			    true);

			self.game.add.tween( self.slides[self.currentslide] )
			    .to({alpha: 1},
			    1500,
			    Phaser.Easing.Linear.None,
			    true);
		    }
		}
	},

	render: function(){

	}
}
