var __extends = this.__extends || function (d, b) {
    for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
    function __() { this.constructor = d; }
    __.prototype = b.prototype;
    d.prototype = new __();
};
var Dzwiek = (function (_super) {
    __extends(Dzwiek, _super);
    function Dzwiek() {
        _super.apply(this, arguments);
    }
    Dzwiek.prototype.preload = function () {
        this.game.load.audio('music', 'sound/AKKA.mp3');
        this.game.load.image('tlo', 'IMAGEE/TLO2.bmp');
        this.game.load.image('play', 'IMAGEE/PLAY.bmp');
        this.game.load.image('pauza', 'IMAGEE/PAUZA.bmp');
        this.game.load.image('resume', 'IMAGEE/RESUME.bmp');
        this.game.load.image('stop', 'IMAGEE/STOP.bmp');
    };

    Dzwiek.prototype.create = function () {
        var tablicaSprite = [];
        var tlo = this.game.add.sprite(this.game.world.centerX, this.game.world.centerY, 'tlo');
        tlo.anchor.setTo(0.5, 0.5);
        tablicaSprite[0] = this.game.add.sprite(100, 400, 'play');
        tablicaSprite[0].anchor.setTo(0.5, 0.5);
        tablicaSprite[1] = this.game.add.sprite(700, 400, 'pauza');
        tablicaSprite[1].anchor.setTo(0.5, 0.5);
        tablicaSprite[2] = this.game.add.sprite(400, 400, 'resume');
        tablicaSprite[2].anchor.setTo(0.5, 0.5);
        tablicaSprite[3] = this.game.add.sprite(400, 500, 'play');
        tablicaSprite[3].anchor.setTo(0.5, 0.5);
        tablicaSprite[4] = this.game.add.sprite(700, 500, 'stop');
        tablicaSprite[4].anchor.setTo(0.5, 0.5);

        tablicaSprite[0].inputEnabled = true;
        tablicaSprite[0].input.useHandCursor = true;
        tablicaSprite[0].events.onInputDown.add(play, this);

        tablicaSprite[1].inputEnabled = true;
        tablicaSprite[1].input.useHandCursor = true;
        tablicaSprite[1].events.onInputDown.add(pause, this);

        tablicaSprite[2].inputEnabled = true;
        tablicaSprite[2].input.useHandCursor = true;
        tablicaSprite[2].events.onInputDown.add(resume, this);

        tablicaSprite[3].inputEnabled = true;
        tablicaSprite[3].input.useHandCursor = true;
        tablicaSprite[3].events.onInputDown.add(play_15, this);

        tablicaSprite[4].inputEnabled = true;
        tablicaSprite[4].input.useHandCursor = true;
        tablicaSprite[4].events.onInputDown.add(stop, this);

        var muzyka = this.game.add.audio('music');

        function play(event, sprite) {
            if (!muzyka.isPlaying && !muzyka.paused)
                muzyka.play('', 0, 0.5, false, true);
        }
        function play_15(event, sprite) {
            if (!muzyka.isPlaying && !muzyka.paused) {
                muzyka.addMarker('1', 1, 2.5, 1, true);
                muzyka.play('1');
            }
        }
        function pause(event, sprite) {
            if (muzyka.isPlaying)
                muzyka.pause();
        }
        function resume(event, sprite) {
            if (muzyka.paused)
                muzyka.resume();
        }
        function stop(event, sprite) {
            if (muzyka.isPlaying || muzyka.paused)
                muzyka.stop();
        }
    };
    return Dzwiek;
})(Phaser.State);
var Klawiatura = (function (_super) {
    __extends(Klawiatura, _super);
    function Klawiatura() {
        _super.apply(this, arguments);
    }
    Klawiatura.prototype.preload = function () {
        this.game.load.audio('music', 'sound/AKKA.mp3');
        this.game.load.image('tlo', 'IMAGEE/TLO2.bmp');
    };

    Klawiatura.prototype.create = function () {
        var tablicaSprite = [];
        var glosnosc = 0.5;
        var tlo = this.game.add.sprite(this.game.world.centerX, this.game.world.centerY, 'tlo');
        tlo.anchor.setTo(0.5, 0.5);

        var playKey = this.game.input.keyboard.addKey(Phaser.Keyboard.P);
        var play_15Key = this.game.input.keyboard.addKey(Phaser.Keyboard.Q);
        var pauseKey = this.game.input.keyboard.addKey(Phaser.Keyboard.A);
        var resumeKey = this.game.input.keyboard.addKey(Phaser.Keyboard.R);
        var stopKey = this.game.input.keyboard.addKey(Phaser.Keyboard.S);
        var kursory = this.game.input.keyboard.createCursorKeys();

        playKey.onUp.add(play, this);
        play_15Key.onDown.add(play_15, this);
        pauseKey.onDown.add(pause, this);
        resumeKey.onDown.add(resume, this);
        stopKey.onDown.add(stop, this);

        kursory.up.onDown.add(glosniej, this);
        kursory.down.onDown.add(ciszej, this);

        var muzyka = this.game.add.audio('music');
        function glosniej() {
            if (glosnosc < 1)
                glosnosc += 0.05;
        }
        function ciszej() {
            if (glosnosc > 0)
                glosnosc -= 0.05;
        }
        function play(event, sprite) {
            if (!muzyka.isPlaying && !muzyka.paused)
                muzyka.play('', 0, glosnosc, false, true);
        }
        function play_15(event, sprite) {
            if (!muzyka.isPlaying && !muzyka.paused) {
                muzyka.addMarker('1', 1, 2.5, glosnosc, true);
                muzyka.play('1');
            }
        }
        function pause(event, sprite) {
            if (muzyka.isPlaying)
                muzyka.pause();
        }
        function resume(event, sprite) {
            if (muzyka.paused)
                muzyka.resume();
        }
        function stop(event, sprite) {
            if (muzyka.isPlaying || muzyka.paused)
                muzyka.stop();
        }
    };
    return Klawiatura;
})(Phaser.State);
var Myszka = (function (_super) {
    __extends(Myszka, _super);
    function Myszka() {
        _super.apply(this, arguments);
    }
    Myszka.prototype.preload = function () {
        this.game.load.image('tlo', 'IMAGEE/TLO.bmp');
        this.game.load.image('tak', 'IMAGEE/TAK.bmp');
        this.game.load.image('nie', 'IMAGEE/NIE.bmp');
        this.game.load.image('nie_chcesz', 'IMAGEE/NIE_CHCESZ.bmp');
    };

    Myszka.prototype.create = function () {
        var tablicaSprite = [];
        var parzystosc10 = 0;
        var tlo = this.game.add.sprite(this.game.world.centerX, this.game.world.centerY, 'tlo');
        tlo.anchor.setTo(0.5, 0.5);
        tablicaSprite[0] = this.game.add.sprite(100, 400, 'tak');
        tablicaSprite[0].anchor.setTo(0.5, 0.5);
        tablicaSprite[0].visible = true;
        tablicaSprite[1] = this.game.add.sprite(700, 400, 'nie');
        tablicaSprite[1].anchor.setTo(0.5, 0.5);
        tablicaSprite[1].visible = true;
        tablicaSprite[2] = this.game.add.sprite(700, 400, 'tak');
        tablicaSprite[2].anchor.setTo(0.5, 0.5);
        tablicaSprite[2].visible = false;
        tablicaSprite[3] = this.game.add.sprite(100, 400, 'nie');
        tablicaSprite[3].anchor.setTo(0.5, 0.5);
        tablicaSprite[3].visible = false;
        tablicaSprite[4] = this.game.add.sprite(400, 500, 'nie_chcesz');
        tablicaSprite[4].anchor.setTo(0.5, 0.5);
        tablicaSprite[4].visible = false;

        var mysz = new Phaser.Mouse(this.game);
        this.game.canvas.addEventListener('mousemove', onMouseMove, true);
        this.game.canvas.addEventListener('mouseup', onMouseDown, true);
        mysz.callbackContext = this.game;
        mysz.mouseMoveCallback = null;
        mysz.mouseDownCallback = null;
        mysz.disabled = false;
        mysz.event = null;

        function onMouseDown(event) {
            if (event.capture) {
                event.preventDefault();
            }
            if (event.mouseMoveCallback) {
                event.mouseMoveCallback.call(event.callbackContext, event);
            }

            if (event.disabled) {
                return;
            }
            if (event.x > 50 && event.x < 150 && event.y > 350 && event.y < 450 && parzystosc10 == 1) {
                tablicaSprite[4].visible = true;
            }
            if (event.x > 650 && event.x < 750 && event.y > 350 && event.y < 450 && parzystosc10 == 0) {
                tablicaSprite[4].visible = true;
            }
        }
        function onMouseMove(event) {
            if (event.capture) {
                event.preventDefault();
            }
            if (event.mouseMoveCallback) {
                event.mouseMoveCallback.call(event.callbackContext, event);
            }

            if (event.disabled) {
                return;
            }
            if (event.x > 50 && event.x < 150 && event.y > 350 && event.y < 450 && parzystosc10 == 0) {
                tablicaSprite[0].visible = false;
                tablicaSprite[1].visible = false;
                tablicaSprite[2].visible = true;
                tablicaSprite[3].visible = true;
                parzystosc10 = 1;
            }
            if (event.x > 650 && event.x < 750 && event.y > 350 && event.y < 450 && parzystosc10 == 1) {
                tablicaSprite[0].visible = true;
                tablicaSprite[1].visible = true;
                tablicaSprite[2].visible = false;
                tablicaSprite[3].visible = false;
                parzystosc10 = 0;
            }
        }
    };
    return Myszka;
})(Phaser.State);
window.onload = function () {
    var game = new Phaser_przyklady();
};
var Phaser_przyklady = (function (_super) {
    __extends(Phaser_przyklady, _super);
    function Phaser_przyklady() {
        _super.call(this, 800, 600, Phaser.AUTO, 'content', null);
        this.state.add('myszka', Myszka, false);
        this.state.add('dzwiek', Dzwiek, false);
        this.state.add('klawiatura', Klawiatura, true);
    }
    return Phaser_przyklady;
})(Phaser.Game);
//# sourceMappingURL=game.js.map
