'use strict';
var play;
var title;
var helper;
var bg;
var sponsors;
Game1.Menu = function() {};
 
  Game1.Menu.prototype = {
   
    create: function() {
      var style = { font: '70px Arial', fill: '#0080ca', align: 'center'};
      bg = this.game.add.sprite(0, 0, 'bg');
        bg.scale.setTo(1/2,1/2);
        sponsors = this.game.add.sprite(0,458,'sponsors');
        sponsors.scale.setTo(1/2,1/2);
      //this.sprite.anchor.setTo(0.5, 0.5);
    //this.sprite.scale.setTo(0.9,0.9);
        
   title = this.game.add.sprite(435/2, 158/2, 'title');
        title.scale.setTo(1/2,1/2);
        helper = this.game.add.sprite(1254/2, 415/2, 'pomocnik');
        helper.scale.setTo(1/2,1/2);
    //this.sprite.anchor.setTo(0.5, 0.5);
            
    //var button = new Phaser.Button(this.game,1302,516,'play_button', this.buttonCallback, this, 1,0,2);
      play = this.game.add.sprite(446/2,686/2,'play_button');
        play.inputEnabled =true;
        play.name = "play";
        play.events.onInputOver.add(this.over,this);
        play.events.onInputDown.add(this.down, this);
        play.events.onInputOut.add(this.out,this);
        // play = this.game.add.button(446/2,686/2,'play_button', this.actionOnClick, this,'','','');
        play.scale.setTo(1/2,1/2);
        // play.onInputOver.add(1, this);
          //  play.onInputOut.add(2,this);
        
    //play =  this.game.add.sprite(446, 686, 'play_button');
   play.inputEnabled = true;
    play.animations.add('off',[0], true);
    play.animations.add('on',[1], true);
        
      
},
onInputOver: function(sprite, pointer){
    
},
down: function(sprite, pointer) {
    this.game.state.start('Game');
    //console.log('button down: '+sprite.name);
},      
over: function(sprite, pointer) {
    play.animations.play('on',1,true,false);
    console.log('button over'+sprite.name);
    if (!this.game.device.desktop)
        this.game.state.start('Game');
},

out: function(sprite, pointer) {
     play.animations.play('off',1,true,false);
    console.log('button out'+sprite.name);
},
      update: function() {
 },

actionOnClick: function() {
 this.game.state.start('Game');

}
  };