var startgame7 = false
var endscreen = {
    preload: function () {
        startgame7 = false
        pageNo = 7
    }
    , create: function () {
         ebackground2 = this.game.add.sprite(400, 300, 'ebackground2');
        ebackground2.anchor.setTo(0.5);
        ebackground2.scale.setTo(1.1);
        mbody = this.game.add.image(549.55, 465.05, 'mbody');
        mbody.anchor.setTo(0.5);
        mblush = this.game.add.image(554.35, 304.25, 'mblush');
        mblush.anchor.setTo(0.5);
        mblush.frame = marr[0]
        mebrow = this.game.add.image(550.35, 185.85, 'mebrow');
        mebrow.anchor.setTo(0.5);
        mebrow.frame = marr[1]
        meshade = this.game.add.image(551.95, 239.45, 'meshade');
        meshade.anchor.setTo(0.5);
        meshade.frame = marr[3]
        meline = this.game.add.image(551.15, 234.65, 'meline');
        meline.anchor.setTo(0.5);
        meline.frame = marr[2]
        mlip = this.game.add.image(555.95, 333.05, 'mlip');
        mlip.anchor.setTo(0.5);
        mlip.frame = marr[4]
        melash = this.game.add.image(554.35, 241.05, 'melash');
        melash.anchor.setTo(0.5);
        melash.frame = marr[5]
        mdress = this.game.add.image(555.95, 639.5, 'mdress');
        mdress.anchor.setTo(0.5);
        mdress.frame = darr[0]
        mchainacc = this.game.add.image(558.4, 419.5, 'macc');
        mchainacc.anchor.setTo(0.5);
        mchainacc.frame = darr[3]
        mhair = this.game.add.image(550.1, 343.05, 'mhair');
        mhair.anchor.setTo(0.5);
        mhair.frame = darr[1]
        mstudacc = this.game.add.image(558.4, 419.5, 'macc');
        mstudacc.anchor.setTo(0.5);
        mstudacc.frame = darr[4]
        mglassacc = this.game.add.image(558.4, 419.5, 'macc');
        mglassacc.anchor.setTo(0.5);
        mglassacc.frame = darr[5]
        mhand = this.game.add.image(551.65, 694.9, 'mhand');
        mhand.anchor.setTo(0.5);
        if (darr[2] == 1) {
            mhair.frame = darr[1] + 7
        }
        else if (darr[2] == 6) {
            mhair.frame = darr[1] + 14
        }
        else {
            mhair.frame = darr[1]
        }
        dollgrp = game.add.group()
        dollgrp.add(mbody)
        dollgrp.add(mblush)
        dollgrp.add(mebrow)
        dollgrp.add(meshade)
        dollgrp.add(meline)
        dollgrp.add(mlip)
        dollgrp.add(melash)
        dollgrp.add(mdress)
        dollgrp.add(mchainacc)
        dollgrp.add(mhair)
        dollgrp.add(mstudacc)
        dollgrp.add(mglassacc)
        dollgrp.add(mhand)
        dollgrp.scale.setTo(0.85)
        dollgrp.x = -70
        dollgrp.y =20
        save1 = this.game.add.image(74.95, 517.25, 'save1');
        save1.anchor.setTo(0.5);
        replay2 = this.game.add.image(201.8, 515.25, 'replay1');
        replay2.anchor.setTo(0.5);
        moregames2 = this.game.add.button(743.95, 508.55, 'moregames1');
        moregames2.anchor.setTo(0.5);
        logofbkmute()
        savegroup = game.add.group();
        savegroup.add(save1);
        savegroup.add(replay2);
        savegroup.add(moregames2);
        savegroup.add(ffck2);
        savegroup.add(mute2);
        leveluppanelReverseFun()
    }
}
function endscreenFun() {
    moregames2.inputEnabled = true;
    moregames2.input.useHandCursor = true;
    moregames2.input.pixelPerfectOver = true;
    moregames2.input.pixelPerfectClick = true;
    moregames2.events.onInputOver.add(moregamesOverFun, this);
    moregames2.events.onInputOut.add(moregamesOutFun, this);
    moregames2.events.onInputDown.add(moregamesFun2, this);
    moregames2.events.onInputUp.add(moregamesFun1, this);
    save1.inputEnabled = true;
    save1.input.useHandCursor = true;
    save1.input.pixelPerfectOver = true;
    save1.input.pixelPerfectClick = true;
    save1.events.onInputOver.add(saveOverFun, this);
    save1.events.onInputOut.add(saveOutFun, this);
    save1.events.onInputDown.add(saveFun1, this);
    save1.events.onInputUp.add(save1Fun1, this);
    replay2.inputEnabled = true;
    replay2.input.useHandCursor = true;
    replay2.input.pixelPerfectOver = true;
    replay2.input.pixelPerfectClick = true;
    replay2.events.onInputOver.add(replay1OverFun, this);
    replay2.events.onInputOut.add(replay1OutFun, this);
    replay2.events.onInputDown.add(replay1Fun1, this);
    replay2.events.onInputUp.add(replay2Fun1, this);
    function replay1OverFun(ev) {
        replay2.frame = 1;
        replayAni = replay2.animations.add('replayAni');
        replayAni.enableUpdate = true;
        replayAni.onUpdate.add(replayonUpdate, this);
        replay2.animations.play('replayAni', 24, false);
    }
    function replayonUpdate(anim, frame) {
        if (anim.frame == 15) {
            anim.stop()
        }
    }
    function replay1OutFun(ev) {
        replay2.animations.stop(null, true);
    }
    function replay2Fun1(ev) {
        if (!startgame7) {
            startgame7 = true;
            ev.frame = 0;
            leveluppanelCreateFun();
        }
    }
    function replay1Fun1(ev) {
        if (!startgame7) {
            playsoundeffects('clickss');
            ev.frame = 16;
        }
    }
    function saveOverFun(ev) {
        save1.frame = 1;
        saveAni = save1.animations.add('saveAni');
        saveAni.enableUpdate = true;
        saveAni.onUpdate.add(saveonUpdate, this);
        save1.animations.play('saveAni', 24, false);
    }
    function saveonUpdate(anim, frame) {
        if (anim.frame == 15) {
            anim.stop()
        }
    }
    function saveOutFun(ev) {
        save1.animations.stop(null, true);
    }
    function saveFun1(ev) {
        playsoundeffects('clickss');
        ev.frame = 16
    }
    function save1Fun1(ev) {
      /*  if (!startgame7) {
            save1.frame = 0;
            savegroup.visible = false;
            setTimeout(callreopratfuns, 500);
            game.capture = game.plugins.add(Phaser.Plugin.Capture);
            game.capture.screenshot(function (dataUrl) {
                var data = new Image();
                data.src = dataUrl;
                game.cache.addImage('image-data', dataUrl, data);
                var canvasImageSaver = new CanvasImageSaver(game.canvas, {
                    xCropOffset: 0
                    , yCropOffset: 0
                    , width: 800
                    , height: game.height
                , }, function (canvas, fileName) {
                    console.log(canvas, fileName);
                }, function (error) {}, this);
                exportCanvasAsPNG(canvas, 'rapunzel_summer_makeup', dataUrl);
            });
        }*/
    }
    function callreopratfuns() {
        savegroup.visible = true;
    }
}