/**
 * Created with JetBrains WebStorm.
 * User: gravis_ihara
 * Date: 14/09/08
 * Time: 18:38
 * To change this template use File | Settings | File Templates.
 */
gravis.SceneTitle = enchant.Class.create(enchant.Group,{
    initialize: function() {
        enchant.Group.call(this);
        //back
        this.back = new enchant.Sprite(480,640);
        this.back.image = gravis.Utility.getImage('back_green.png');
        this.addChild(this.back);
        //copyright
        this.copyright = new enchant.Sprite(264,17);
        this.copyright.moveTo(108, 545);
        this.copyright.image = gravis.Utility.getImage('gravis.png');
        this.addChild(this.copyright);
        //title
        this.title = new enchant.Sprite(480,320);
        this.title.image = gravis.Utility.getImage('title.png');
        this.addChild(this.title);
        //Player x Cpu
        var base_y = 435;
        this.btnCpu = new enchant.Sprite(480,75);
        this.btnCpu.moveTo(0,base_y-110);
        this.btnCpu.image = gravis.Utility.getImage('button_01.png');
        this.btnCpu.frame = 2;
        this.btnCpu.addEventListener('touchstart', function(){
           this.frame = 3;
        });
        this.btnCpu.addEventListener('touchend', function(e){
            this.frame = 2;
            if( gravis.Utility.isTap(this, e) ) {
                var slider = new gravis.SliderScene("Choice Start Level","GO","BACK");
                slider.callback = function(accept) {
                    if( accept ) {
                        gameManager.sceneGame.cpuLevel = slider.level;
                        gameManager.sceneGame.versus = gravis.SceneGame.VERSUS_COMPUTER;
                        gameManager.changeScene(gravis.GameManager.APPSTATE_GAME);

                        gravis.Utility.savedata.cpu = slider.level;
                        gravis.Utility.save();
                    }
                };
                game.pushScene(slider);
            }
        });
        this.addChild(this.btnCpu);
        //Player x Player
        this.btnPlayer = new enchant.Sprite(480,75);
        this.btnPlayer.moveTo(0,base_y-35);
        this.btnPlayer.image = gravis.Utility.getImage('button_01.png');
        this.btnPlayer.frame = 0;
        this.btnPlayer.addEventListener('touchstart', function(){
            this.frame = 1;
        });
        this.btnPlayer.addEventListener('touchend', function(e){
            this.frame = 0;
            if( gravis.Utility.isTap(this, e) ) {
                gameManager.sceneGame.versus = gravis.SceneGame.VERSUS_PLAYER;
                gameManager.changeScene(gravis.GameManager.APPSTATE_GAME);
            }
        });
        this.addChild(this.btnPlayer);
        //sound
        this.sound = new enchant.Sprite(48,48);
        this.sound.moveTo(418,20);
        this.sound.image = gravis.Utility.getImage('volume.png');
        this.sound.frame = gravis.Utility.savedata.sound ? 1 : 0;
        this.sound.addEventListener('touchstart', function(){
            if( this.frame == 0 ) {
                this.frame = 1;
                gravis.Utility.savedata.sound = true;
            } else {
                this.frame = 0;
                gravis.Utility.savedata.sound = false;
            }
            gravis.Utility.save();
        });
        this.addChild(this.sound);

    },

    start: function() {
        gameManager.sceneGame.win_num_1 = 0;
        gameManager.sceneGame.win_num_2 = 0;
        gameManager.sceneGame.draw_num = 0;
    },

    end: function() {
    },

    proc: function() {
    },

    draw: function() {
    }
});