Ir ao conteúdo

Posts recomendados

Postado

Estou usando no head:

 

<?php $link = "http://" . $_SERVER['HTTP_HOST'] . "/phaser-3.54.0/dist/phaser.js"; ?>
<script type="text/javascript" src="<?php echo $link; ?>"></script>

 

Meu código do Phaser 3 é:

 

var Idioma = new Phaser.Class({

    Extends: Phaser.Scene,

    initialize: function ()
    {
        Phaser.Scene.call(this, { "key": "Idioma" });
    },

    preload: function ()
    {
        this.load.image('botao', 'http://' + window.location.hostname + '/assets/game/temas_festa_selecao/assets/botao.png');
        this.load.image('fundo', 'http://' + window.location.hostname + '/assets/game/temas_festa_selecao/assets/fundo.png');
        this.load.audio('menu_creditos_idioma', 'http://' + window.location.hostname + '/assets/game/temas_festa_selecao/assets/sfx/menu_creditos_idioma.ogg');
        this.load.audio('seleciona_tema', 'http://' + window.location.hostname + '/assets/game/temas_festa_selecao/assets/sfx/seleciona_tema.ogg');
        this.load.audio('desseleciona_tema', 'http://' + window.location.hostname + '/assets/game/temas_festa_selecao/assets/sfx/desseleciona_tema.ogg');
        this.load.audio('acerta_selecao', 'http://' + window.location.hostname + '/assets/game/temas_festa_selecao/assets/sfx/acerta_selecao.ogg');
        this.load.audio('erra_selecao', 'http://' + window.location.hostname + '/assets/game/temas_festa_selecao/assets/sfx/erra_selecao.ogg');
        this.load.audio('inicio_jogo', 'http://' + window.location.hostname + '/assets/game/temas_festa_selecao/assets/sfx/inicio_jogo.ogg');
        this.load.audio('fim_jogo', 'http://' + window.location.hostname + '/assets/game/temas_festa_selecao/assets/sfx/fim_jogo.ogg');
    },

    create: function ()
    {
        this.add.image(480, 270, 'fundo');
        const screenCenterX = this.cameras.main.worldView.x + this.cameras.main.width / 2;
        const screenCenterY = this.cameras.main.worldView.y + this.cameras.main.height / 2;
        var sfxMenuCreditosIdioma = this.sound.add('menu_creditos_idioma', {
            mute: false,
            volume: 1,
            rate: 1,
            detune: 0,
            seek: 0,
            loop: false,
            delay: 0
        });
        var sfxSelecionaTema = this.sound.add('seleciona_tema', {
            mute: false,
            volume: 1,
            rate: 1,
            detune: 0,
            seek: 0,
            loop: false,
            delay: 0
        });
        var sfxDesselecionaTema = this.sound.add('desseleciona_tema', {
            mute: false,
            volume: 1,
            rate: 1,
            detune: 0,
            seek: 0,
            loop: false,
            delay: 0
        });
        var sfxAcertaSelecao = this.sound.add('acerta_selecao', {
            mute: false,
            volume: 1,
            rate: 1,
            detune: 0,
            seek: 0,
            loop: false,
            delay: 0
        });
        var sfxErraSelecao = this.sound.add('erra_selecao', {
            mute: false,
            volume: 1,
            rate: 1,
            detune: 0,
            seek: 0,
            loop: false,
            delay: 0
        });
        var sfxInicioJogo = this.sound.add('inicio_jogo', {
            mute: false,
            volume: 1,
            rate: 1,
            detune: 0,
            seek: 0,
            loop: false,
            delay: 0
        });
        var sfxFimJogo = this.sound.add('fim_jogo', {
            mute: false,
            volume: 1,
            rate: 1,
            detune: 0,
            seek: 0,
            loop: false,
            delay: 0
        });
        this.sfx = [sfxMenuCreditosIdioma, sfxSelecionaTema, sfxDesselecionaTema, sfxAcertaSelecao, sfxErraSelecao, sfxInicioJogo, sfxFimJogo];
        this.botaoPT = this.add.image(75, 25, 'botao').setPosition(screenCenterX, screenCenterY - 80);
        this.textoPT = this.add.text(screenCenterX, screenCenterY - 80, 'Português', {fontSize: '16pt', color: 'white', fontFamily: 'Arial Regular'}).setOrigin(0.5);
        this.botaoPT.setInteractive({ cursor: 'url(\'http://' + window.location.hostname + '/assets/game/temas_festa_selecao/assets/mouse-cursor-pointer.png\'), pointer' });
        this.botaoPT.on('pointerup', function () {
            this.scene.scene.start('MenuPT', MenuPT);
        });
    },

    update: function ()
    {

    }

});

var MenuPT = new Phaser.Class({

    Extends: Phaser.Scene,

    initialize: function ()
    {
        Phaser.Scene.call(this, { "key": "MenuPT" });
    },

    preload: function ()
    {
        this.load.image('botao', 'http://' + window.location.hostname + '/assets/game/temas_festa_selecao/assets/botao.png');
        this.load.image('fundo', 'http://' + window.location.hostname + '/assets/game/temas_festa_selecao/assets/fundo.png');
        this.load.audio('menu_creditos_idioma', 'http://' + window.location.hostname + '/assets/game/temas_festa_selecao/assets/sfx/menu_creditos_idioma.ogg');
        this.load.audio('seleciona_tema', 'http://' + window.location.hostname + '/assets/game/temas_festa_selecao/assets/sfx/seleciona_tema.ogg');
        this.load.audio('desseleciona_tema', 'http://' + window.location.hostname + '/assets/game/temas_festa_selecao/assets/sfx/desseleciona_tema.ogg');
        this.load.audio('acerta_selecao', 'http://' + window.location.hostname + '/assets/game/temas_festa_selecao/assets/sfx/acerta_selecao.ogg');
        this.load.audio('erra_selecao', 'http://' + window.location.hostname + '/assets/game/temas_festa_selecao/assets/sfx/erra_selecao.ogg');
        this.load.audio('inicio_jogo', 'http://' + window.location.hostname + '/assets/game/temas_festa_selecao/assets/sfx/inicio_jogo.ogg');
        this.load.audio('fim_jogo', 'http://' + window.location.hostname + '/assets/game/temas_festa_selecao/assets/sfx/fim_jogo.ogg');
    },

    create: function ()
    {
        this.add.image(480, 270, 'fundo');
        const titulo = 'Jogo dos Temas de Festa\nde Aniversário pela Seleção';
        const screenCenterX = this.cameras.main.worldView.x + this.cameras.main.width / 2;
        const screenCenterY = this.cameras.main.worldView.y + this.cameras.main.height / 2;
        var sfxMenuCreditosIdioma = this.sound.add('menu_creditos_idioma', {
            mute: false,
            volume: 1,
            rate: 1,
            detune: 0,
            seek: 0,
            loop: false,
            delay: 0
        });
        var sfxSelecionaTema = this.sound.add('seleciona_tema', {
            mute: false,
            volume: 1,
            rate: 1,
            detune: 0,
            seek: 0,
            loop: false,
            delay: 0
        });
        var sfxDesselecionaTema = this.sound.add('desseleciona_tema', {
            mute: false,
            volume: 1,
            rate: 1,
            detune: 0,
            seek: 0,
            loop: false,
            delay: 0
        });
        var sfxAcertaSelecao = this.sound.add('acerta_selecao', {
            mute: false,
            volume: 1,
            rate: 1,
            detune: 0,
            seek: 0,
            loop: false,
            delay: 0
        });
        var sfxErraSelecao = this.sound.add('erra_selecao', {
            mute: false,
            volume: 1,
            rate: 1,
            detune: 0,
            seek: 0,
            loop: false,
            delay: 0
        });
        var sfxInicioJogo = this.sound.add('inicio_jogo', {
            mute: false,
            volume: 1,
            rate: 1,
            detune: 0,
            seek: 0,
            loop: false,
            delay: 0
        });
        var sfxFimJogo = this.sound.add('fim_jogo', {
            mute: false,
            volume: 1,
            rate: 1,
            detune: 0,
            seek: 0,
            loop: false,
            delay: 0
        });
        this.sfx = [sfxMenuCreditosIdioma, sfxSelecionaTema, sfxDesselecionaTema, sfxAcertaSelecao, sfxErraSelecao, sfxInicioJogo, sfxFimJogo];
        this.tituloTexto = this.add.text(screenCenterX, 80, titulo, {fontSize: '30pt', color: 'white', align: 'center', fontFamily: 'Arial Regular'}).setOrigin(0.5);
        this.botaoJogar = this.add.image(75, 25, 'botao').setPosition(160, 420);
        this.textoJogar = this.add.text(160, 420, 'Jogar', {fontSize: '16pt', color: 'white', fontFamily: 'Arial Regular'}).setOrigin(0.5);
        this.botaoCreditos = this.add.image(75, 25, 'botao').setPosition(screenCenterX, 420);
        this.textoCreditos = this.add.text(screenCenterX, 420, 'Créditos', {fontSize: '16pt', color: 'white', fontFamily: 'Arial Regular'}).setOrigin(0.5);
        this.botaoIdioma = this.add.image(75, 25, 'botao').setPosition(800, 420);
        this.textoIdioma = this.add.text(800, 420, 'Idioma', {fontSize: '16pt', color: 'white', fontFamily: 'Arial Regular'}).setOrigin(0.5);
        this.botaoJogar.setInteractive({ cursor: 'url(\'http://' + window.location.hostname + '/assets/game/temas_festa_selecao/assets/mouse-cursor-pointer.png\'), pointer' });
        this.botaoCreditos.setInteractive({ cursor: 'url(\'http://' + window.location.hostname + '/assets/game/temas_festa_selecao/assets/mouse-cursor-pointer.png\'), pointer' });
        this.botaoIdioma.setInteractive({ cursor: 'url(\'http://' + window.location.hostname + '/assets/game/temas_festa_selecao/assets/mouse-cursor-pointer.png\'), pointer' });
        this.botaoCreditos.on('pointerup', function () {
            this.scene.scene.start('CreditosPT', CreditosPT);
        });
        this.botaoIdioma.on('pointerup', function () {
            this.scene.scene.start('Idioma', Idioma);
        });
        this.botaoJogar.on('pointerup', function () {
            this.scene.scene.start('JogoPT', JogoPT);
        });
    },

    update: function ()
    {

    }

});

var CreditosPT = new Phaser.Class({

    Extends: Phaser.Scene,

    initialize: function ()
    {
        Phaser.Scene.call(this, { "key": "CreditosPT" });
    },

    preload: function ()
    {
        this.load.image('botao', 'http://' + window.location.hostname + '/assets/game/temas_festa_selecao/assets/botao.png');
        this.load.image('fundo', 'http://' + window.location.hostname + '/assets/game/temas_festa_selecao/assets/fundo.png');
        this.load.audio('menu_creditos_idioma', 'http://' + window.location.hostname + '/assets/game/temas_festa_selecao/assets/sfx/menu_creditos_idioma.ogg');
        this.load.audio('seleciona_tema', 'http://' + window.location.hostname + '/assets/game/temas_festa_selecao/assets/sfx/seleciona_tema.ogg');
        this.load.audio('desseleciona_tema', 'http://' + window.location.hostname + '/assets/game/temas_festa_selecao/assets/sfx/desseleciona_tema.ogg');
        this.load.audio('acerta_selecao', 'http://' + window.location.hostname + '/assets/game/temas_festa_selecao/assets/sfx/acerta_selecao.ogg');
        this.load.audio('erra_selecao', 'http://' + window.location.hostname + '/assets/game/temas_festa_selecao/assets/sfx/erra_selecao.ogg');
        this.load.audio('inicio_jogo', 'http://' + window.location.hostname + '/assets/game/temas_festa_selecao/assets/sfx/inicio_jogo.ogg');
        this.load.audio('fim_jogo', 'http://' + window.location.hostname + '/assets/game/temas_festa_selecao/assets/sfx/fim_jogo.ogg');
    },

    create: function ()
    {
        this.add.image(480, 270, 'fundo');
        const screenCenterX = this.cameras.main.worldView.x + this.cameras.main.width / 2;
        const screenCenterY = this.cameras.main.worldView.y + this.cameras.main.height / 2;
        var sfxMenuCreditosIdioma = this.sound.add('menu_creditos_idioma', {
            mute: false,
            volume: 1,
            rate: 1,
            detune: 0,
            seek: 0,
            loop: false,
            delay: 0
        });
        var sfxSelecionaTema = this.sound.add('seleciona_tema', {
            mute: false,
            volume: 1,
            rate: 1,
            detune: 0,
            seek: 0,
            loop: false,
            delay: 0
        });
        var sfxDesselecionaTema = this.sound.add('desseleciona_tema', {
            mute: false,
            volume: 1,
            rate: 1,
            detune: 0,
            seek: 0,
            loop: false,
            delay: 0
        });
        var sfxAcertaSelecao = this.sound.add('acerta_selecao', {
            mute: false,
            volume: 1,
            rate: 1,
            detune: 0,
            seek: 0,
            loop: false,
            delay: 0
        });
        var sfxErraSelecao = this.sound.add('erra_selecao', {
            mute: false,
            volume: 1,
            rate: 1,
            detune: 0,
            seek: 0,
            loop: false,
            delay: 0
        });
        var sfxInicioJogo = this.sound.add('inicio_jogo', {
            mute: false,
            volume: 1,
            rate: 1,
            detune: 0,
            seek: 0,
            loop: false,
            delay: 0
        });
        var sfxFimJogo = this.sound.add('fim_jogo', {
            mute: false,
            volume: 1,
            rate: 1,
            detune: 0,
            seek: 0,
            loop: false,
            delay: 0
        });
        this.sfx = [sfxMenuCreditosIdioma, sfxSelecionaTema, sfxDesselecionaTema, sfxAcertaSelecao, sfxErraSelecao, sfxInicioJogo, sfxFimJogo];
        this.creditosTexto = this.add.text(screenCenterX, 120, 'Victor Lima fez os efeitos sonoros.\n\nAna Luiza da Silva Holdefer e Morgana Luiza\nSbrussi Granella contribuíram com\nos temas e seus elementos.', {fontSize: '24pt', color: 'white', align: 'center', fontFamily: 'Arial Regular'}).setOrigin(0.5);
        this.botaoVoltar = this.add.image(75, 25, 'botao').setPosition(screenCenterX, 420);
        this.textoVoltar = this.add.text(screenCenterX, 420, 'Voltar', {fontSize: '16pt', color: 'white', fontFamily: 'Arial Regular'}).setOrigin(0.5);
        this.botaoVoltar.setInteractive({ cursor: 'url(\'http://' + window.location.hostname + '/assets/game/temas_festa_selecao/assets/mouse-cursor-pointer.png\'), pointer' });
        this.botaoVoltar.on('pointerup', function () {
            this.scene.scene.start('MenuPT', MenuPT);
        });
    },

    update: function ()
    {

    }

});

var JogoPT = new Phaser.Class({

    Extends: Phaser.Scene,

    initialize: function ()
    {
        Phaser.Scene.call(this, { "key": "JogoPT" });
    },

    preload: function ()
    {
        this.load.image('botao', 'http://' + window.location.hostname + '/assets/game/temas_festa_selecao/assets/botao.png');
        this.load.image('fundo', 'http://' + window.location.hostname + '/assets/game/temas_festa_selecao/assets/fundo.png');
        this.load.image('selecionados', 'http://' + window.location.hostname + '/assets/game/temas_festa_selecao/assets/selecionados.png');
        this.load.image('selecionar', 'http://' + window.location.hostname + '/assets/game/temas_festa_selecao/assets/selecionar.png');
        this.load.audio('menu_creditos_idioma', 'http://' + window.location.hostname + '/assets/game/temas_festa_selecao/assets/sfx/menu_creditos_idioma.ogg');
        this.load.audio('seleciona_tema', 'http://' + window.location.hostname + '/assets/game/temas_festa_selecao/assets/sfx/seleciona_tema.ogg');
        this.load.audio('desseleciona_tema', 'http://' + window.location.hostname + '/assets/game/temas_festa_selecao/assets/sfx/desseleciona_tema.ogg');
        this.load.audio('acerta_selecao', 'http://' + window.location.hostname + '/assets/game/temas_festa_selecao/assets/sfx/acerta_selecao.ogg');
        this.load.audio('erra_selecao', 'http://' + window.location.hostname + '/assets/game/temas_festa_selecao/assets/sfx/erra_selecao.ogg');
        this.load.audio('inicio_jogo', 'http://' + window.location.hostname + '/assets/game/temas_festa_selecao/assets/sfx/inicio_jogo.ogg');
        this.load.audio('fim_jogo', 'http://' + window.location.hostname + '/assets/game/temas_festa_selecao/assets/sfx/fim_jogo.ogg');
    },

    create: function ()
    {
        this.add.image(480, 270, 'fundo');
        const screenCenterX = this.cameras.main.worldView.x + this.cameras.main.width / 2;
        const screenCenterY = this.cameras.main.worldView.y + this.cameras.main.height / 2;
        var sfxMenuCreditosIdioma = this.sound.add('menu_creditos_idioma', {
		    mute: false,
		    volume: 1,
		    rate: 1,
		    detune: 0,
		    seek: 0,
		    loop: false,
		    delay: 0
		});
        var sfxSelecionaTema = this.sound.add('seleciona_tema', {
		    mute: false,
		    volume: 1,
		    rate: 1,
		    detune: 0,
		    seek: 0,
		    loop: false,
		    delay: 0
		});
        var sfxDesselecionaTema = this.sound.add('desseleciona_tema', {
		    mute: false,
		    volume: 1,
		    rate: 1,
		    detune: 0,
		    seek: 0,
		    loop: false,
		    delay: 0
		});
        var sfxAcertaSelecao = this.sound.add('acerta_selecao', {
		    mute: false,
		    volume: 1,
		    rate: 1,
		    detune: 0,
		    seek: 0,
		    loop: false,
		    delay: 0
		});
        var sfxErraSelecao = this.sound.add('erra_selecao', {
		    mute: false,
		    volume: 1,
		    rate: 1,
		    detune: 0,
		    seek: 0,
		    loop: false,
		    delay: 0
		});
        var sfxInicioJogo = this.sound.add('inicio_jogo', {
		    mute: false,
		    volume: 1,
		    rate: 1,
		    detune: 0,
		    seek: 0,
		    loop: false,
		    delay: 0
		});
        var sfxFimJogo = this.sound.add('fim_jogo', {
		    mute: false,
		    volume: 1,
		    rate: 1,
		    detune: 0,
		    seek: 0,
		    loop: false,
		    delay: 0
		});
        this.sfx = [sfxMenuCreditosIdioma, sfxSelecionaTema, sfxDesselecionaTema, sfxAcertaSelecao, sfxErraSelecao, sfxInicioJogo, sfxFimJogo];
        this.sfx[5].play();
        var botaoTemaSelecionar01 = this.add.image(80, 40, 'selecionar').setPosition(screenCenterX - 380, screenCenterY - 210);
        var botaoTemaSelecionar02 = this.add.image(80, 40, 'selecionar').setPosition(screenCenterX - 200, screenCenterY - 210);
        var botaoTemaSelecionar03 = this.add.image(80, 40, 'selecionar').setPosition(screenCenterX - 20, screenCenterY - 210);
        var botaoTemaSelecionar04 = this.add.image(80, 40, 'selecionar').setPosition(screenCenterX + 160, screenCenterY - 210);
        var botaoTemaSelecionar05 = this.add.image(80, 40, 'selecionar').setPosition(screenCenterX - 380, screenCenterY - 110);
        var botaoTemaSelecionar06 = this.add.image(80, 40, 'selecionar').setPosition(screenCenterX - 200, screenCenterY - 110);
        var botaoTemaSelecionar07 = this.add.image(80, 40, 'selecionar').setPosition(screenCenterX - 20, screenCenterY - 110);
        var botaoTemaSelecionar08 = this.add.image(80, 40, 'selecionar').setPosition(screenCenterX + 160, screenCenterY - 110);
        var botaoTemaSelecionar09 = this.add.image(80, 40, 'selecionar').setPosition(screenCenterX - 380, screenCenterY - 10);
        var botaoTemaSelecionar10 = this.add.image(80, 40, 'selecionar').setPosition(screenCenterX - 200, screenCenterY - 10);
        var botaoTemaSelecionar11 = this.add.image(80, 40, 'selecionar').setPosition(screenCenterX - 20, screenCenterY - 10);
        var botaoTemaSelecionar12 = this.add.image(80, 40, 'selecionar').setPosition(screenCenterX + 160, screenCenterY - 10);
        var botaoTemaSelecionar13 = this.add.image(80, 40, 'selecionar').setPosition(screenCenterX - 380, screenCenterY + 90);
        var botaoTemaSelecionar14 = this.add.image(80, 40, 'selecionar').setPosition(screenCenterX - 200, screenCenterY + 90);
        var botaoTemaSelecionar15 = this.add.image(80, 40, 'selecionar').setPosition(screenCenterX - 20, screenCenterY + 90);
        var botaoTemaSelecionar16 = this.add.image(80, 40, 'selecionar').setPosition(screenCenterX + 160, screenCenterY + 90);
        this.botoesTemasSelecionar = [botaoTemaSelecionar01, botaoTemaSelecionar02, botaoTemaSelecionar03, botaoTemaSelecionar04, botaoTemaSelecionar05, botaoTemaSelecionar06, botaoTemaSelecionar07, botaoTemaSelecionar08, botaoTemaSelecionar09, botaoTemaSelecionar10, botaoTemaSelecionar11, botaoTemaSelecionar12, botaoTemaSelecionar13, botaoTemaSelecionar14, botaoTemaSelecionar15, botaoTemaSelecionar16];
        var botaoTemaSelecionados01 = this.add.image(80, 40, 'selecionados').setPosition(screenCenterX - 380, screenCenterY - 210);
        var botaoTemaSelecionados02 = this.add.image(80, 40, 'selecionados').setPosition(screenCenterX - 200, screenCenterY - 210);
        var botaoTemaSelecionados03 = this.add.image(80, 40, 'selecionados').setPosition(screenCenterX - 20, screenCenterY - 210);
        var botaoTemaSelecionados04 = this.add.image(80, 40, 'selecionados').setPosition(screenCenterX + 160, screenCenterY - 210);
        var botaoTemaSelecionados05 = this.add.image(80, 40, 'selecionados').setPosition(screenCenterX - 380, screenCenterY - 110);
        var botaoTemaSelecionados06 = this.add.image(80, 40, 'selecionados').setPosition(screenCenterX - 200, screenCenterY - 110);
        var botaoTemaSelecionados07 = this.add.image(80, 40, 'selecionados').setPosition(screenCenterX - 20, screenCenterY - 110);
        var botaoTemaSelecionados08 = this.add.image(80, 40, 'selecionados').setPosition(screenCenterX + 160, screenCenterY - 110);
        var botaoTemaSelecionados09 = this.add.image(80, 40, 'selecionados').setPosition(screenCenterX - 380, screenCenterY - 10);
        var botaoTemaSelecionados10 = this.add.image(80, 40, 'selecionados').setPosition(screenCenterX - 200, screenCenterY - 10);
        var botaoTemaSelecionados11 = this.add.image(80, 40, 'selecionados').setPosition(screenCenterX - 20, screenCenterY - 10);
        var botaoTemaSelecionados12 = this.add.image(80, 40, 'selecionados').setPosition(screenCenterX + 160, screenCenterY - 10);
        var botaoTemaSelecionados13 = this.add.image(80, 40, 'selecionados').setPosition(screenCenterX - 380, screenCenterY + 90);
        var botaoTemaSelecionados14 = this.add.image(80, 40, 'selecionados').setPosition(screenCenterX - 200, screenCenterY + 90);
        var botaoTemaSelecionados15 = this.add.image(80, 40, 'selecionados').setPosition(screenCenterX - 20, screenCenterY + 90);
        var botaoTemaSelecionados16 = this.add.image(80, 40, 'selecionados').setPosition(screenCenterX + 160, screenCenterY + 90);
        this.botoesTemasSelecionados = [botaoTemaSelecionados01, botaoTemaSelecionados02, botaoTemaSelecionados03, botaoTemaSelecionados04, botaoTemaSelecionados05, botaoTemaSelecionados06, botaoTemaSelecionados07, botaoTemaSelecionados08, botaoTemaSelecionados09, botaoTemaSelecionados10, botaoTemaSelecionados11, botaoTemaSelecionados12, botaoTemaSelecionados13, botaoTemaSelecionados14, botaoTemaSelecionados15, botaoTemaSelecionados16];
        for(var i = 0; i < 16; i++){
            this.botoesTemasSelecionados[i].setVisible(false);
        }
        var temasCompleto = ["Tema Abelhas", "Tema Amor", "Tema Ano Novo", "Tema\nArtes\nMarciais", "Autismo", "Tema Aventura", "Tema Cafeteria", "Tema Carnaval", "Tema Cataratas", "Tema Caverna\nde Cristal", "Tema Celeste", "Tema Cidade", "Tema Cineasta", "Tema Circense", "Tema Colorido", "Tema Crianças", "Tema Culinária", "Tema Desértico", "Tema Dislexia", "Tema Eletricidade", "Tema Escolar", "Tema Espacial", "Tema Espiritual", "Tema Esportivo", "Tema Fazenda", "Tema Floresta", "Tema Futuro", "Tema Gótico", "Tema\nHabilidades\nSociais", "Tema Halloween", "Tema Idosos", "Tema Índios", "Tema Industrial", "Tema Inverno", "Tema Jogos\nEletrônicos", "Tema Mágica", "Tema Marinho", "Tema Medieval", "Tema Montanhas", "Tema Museu", "Tema Musical", "Tema Natal", "Tema Noturno", "Tema Outono", "Tema Páscoa", "Tema Piratas", "Tema\nPré-Histórico", "Tema Primavera", "Tema Redes\nSociais", "Tema Saúde", "Tema Segurança", "Tema Teatral", "Tema Transporte", "Tema Turístico", "Tema Verão", "Tema Vulcânico"];
        for(var i = 0; i < 56; i++){
            var aux = temasCompleto[i];
            var r = Number((Math.random() * 56).toString().split(".")[0]);
            temasCompleto[i] = temasCompleto[r];
            temasCompleto[r] = aux;
        }
        for(var i = 1; i <= 40; i++){
            temasCompleto.pop();
        }
        this.temasListaNomes = temasCompleto;
        var temasListaTextosVar = [];
        for(var i = 0; i < 16; i++){
            temasListaTextosVar[i] = this.add.text(this.botoesTemasSelecionar[i].x, this.botoesTemasSelecionar[i].y, this.temasListaNomes[i], {fontSize: '10pt', color: 'black', fontFamily: 'Arial Regular', align: 'center'}).setOrigin(0.5);
        }
        this.temasListaTextosAtri = temasListaTextosVar;
        for(var i = 0; i < 16; i++){
            if(this.botoesTemasSelecionar[i].visible) this.botoesTemasSelecionar[i].setInteractive({ cursor: 'url(\'http://' + window.location.hostname + '/assets/game/temas_festa_selecao/assets/mouse-cursor-pointer.png\'), pointer' });
            if(this.botoesTemasSelecionados[i].visible) this.botoesTemasSelecionados[i].setInteractive({ cursor: 'url(\'http://' + window.location.hostname + '/assets/game/temas_festa_selecao/assets/mouse-cursor-pointer.png\'), pointer' });
        }
        this.elementos = [];
        this.ativo = true;
        this.k = 0;
        this.todosElementosVisitados = false;
        this.numeroTempo = 2701;
        this.textoTempo = this.add.text(screenCenterX - 300, screenCenterY + 210, '2701', {fontSize: '16pt', color: 'white', fontFamily: 'Arial Regular'}).setOrigin(0.5);
        this.botaoEnviar = this.add.image(75, 25, 'botao').setPosition(screenCenterX + 300, screenCenterY + 210);
        this.textoEnviar = this.add.text(screenCenterX + 300, screenCenterY + 210, 'Enviar', {fontSize: '16pt', color: 'white', fontFamily: 'Arial Regular'}).setOrigin(0.5);
        this.numeroPontuacao = 0;
        this.numeroRecord = 0;
        this.numeroErros = 0;
        this.textoElemento = this.add.text(screenCenterX, screenCenterY + 190, 'Elemento', {fontSize: '16pt', color: 'white', fontFamily: 'Arial Regular'}).setOrigin(0.5);
        this.textoStatus = this.add.text(screenCenterX, screenCenterY + 230, 'Pendente!', {fontSize: '16pt', color: 'white', fontFamily: 'Arial Regular'}).setOrigin(0.5);
        this.textoPontuacao = this.add.text(screenCenterX + 360, screenCenterY - 180, 'Pontuação: 0000', {fontSize: '16pt', color: 'white', fontFamily: 'Arial Regular'}).setOrigin(0.5);
        this.textoRecord = this.add.text(screenCenterX + 360, screenCenterY - 140, 'Récorde: 0000', {fontSize: '16pt', color: 'white', fontFamily: 'Arial Regular'}).setOrigin(0.5);
        this.textoErros = this.add.text(screenCenterX + 360, screenCenterY - 100, 'Erros: 0000', {fontSize: '16pt', color: 'white', fontFamily: 'Arial Regular'}).setOrigin(0.5);
        this.botaoEnviar.setInteractive({ cursor: 'url(\'http://' + window.location.hostname + '/assets/game/temas_festa_selecao/assets/mouse-cursor-pointer.png\'), pointer' });

        this.botaoEnviar.on('pointerup', function () {
            if(this.textoStatus.text == "Terminou o Jogo!")
            {
            	this.scene.scene.start('MenuPT', MenuPT);
            }
            else if(this.textoStatus.text == "Incorreto!")
            {
            	this.k++;
            	this.textoElemento.setText('Elemento ' + this.elementos[this.k]);
            	this.textoStatus.setText("Pendente!");
            	this.numeroPontuacao = 0;
            	this.textoPontuacao.setText('Pontuação: ' + this.adicionarZeros(this.numeroPontuacao));
            	this.numeroErros++;
            	this.textoErros.setText('Erros: ' + this.adicionarZeros(this.numeroErros));
            	if(this.k >= this.elementos.length) ativo = false;
            }
            else if(this.textoStatus.text == "Correto!")
            {
            	this.k++;
            	this.textoElemento.setText('Elemento ' + this.elementos[this.k]);
            	this.textoStatus.setText("Pendente!");
            	this.numeroPontuacao++;
            	this.textoPontuacao.setText('Pontuação: ' + this.adicionarZeros(this.numeroPontuacao));
            	if(this.numeroPontuacao > this.numeroRecord)
            	{
            		this.numeroRecord = this.numeroPontuacao;
            		this.textoRecord.setText('Récorde: ' + this.adicionarZeros(this.numeroRecord));
            	}
            	if(this.k >= this.elementos.length) ativo = false;
            }
        });
    },

    update: function ()
    {
        if(this.ativo){
    	    this.textoTempo.setText(this.adicionarZeros(this.numeroTempo));
    	    this.numeroTempo = this.numeroTempo - (1 / 60);
    		if(this.numeroTempo < 1) {
                this.numeroTempo = 0;
                this.textoTempo.setText(this.adicionarZeros(this.numeroTempo));
                this.sfx[6].play();
                this.ativo = false;
            }
            for(var i = 0; i < 16; i++){
                if(this.botoesTemasSelecionar[i].visible) this.botoesTemasSelecionar[i].on('pointerup', function () {
                    this.sfx[1].play();
                    this.botoesTemasSelecionar[i].setVisible(false);
                    this.botoesTemasSelecionados[i].setVisible(true);
                });
                if(this.botoesTemasSelecionados[i].visible) this.botoesTemasSelecionados[i].on('pointerup', function () {
                    this.sfx[2].play();
                    this.botoesTemasSelecionados[i].setVisible(false);
                    this.botoesTemasSelecionar[i].setVisible(true);
                });
            }
    	}
    },

    adicionarZeros: function (numero)
    {
        if(numero < 10) return '000' + (numero).toString().split(".")[0];
        else if(numero < 100) return '00' + (numero).toString().split(".")[0];
        else if(numero < 1000) return '0' + (numero).toString().split(".")[0];
        else return (numero).toString().split(".")[0];
    }

});

const config = {
    type: Phaser.AUTO,
    width: 960,
    height: 540,
    parent: 'testando_phaser',
    scene: [ Idioma, MenuPT, CreditosPT, JogoPT ],
    physics: {
        default: 'arcade',
        arcade: {
            gravity: { y: 300 },
            debug: false
        }
    },
};

const game = new Phaser.Game(config);

 

Nesta parte:

 

if(this.botoesTemasSelecionar[i].visible) this.botoesTemasSelecionar[i].on('pointerup', function () {
    this.sfx[1].play();
    this.botoesTemasSelecionar[i].setVisible(false);
    this.botoesTemasSelecionados[i].setVisible(true);
});

 

Meu erro está aqui:

 

this.sfx[1].play();

 

Postado

@Eduardo de Quadros O caminho aqui é debugar esse codigo, já tentou parar o javascript na linha e ver o conteúdo ? 

 

Essa mensagem undefined é bem clara, você tá chamando um método de uma variável que n tem nada definido nela.

 

Aqui tem um passo a passo de como ver o que tem dentro dessas variáveis exatamente na hora que o método é chamado: 

https://developer.chrome.com/docs/devtools/javascript/

 

Não conheço o Framework, mas o processo de Debug é bem parecido, se o código roda em node.js você pode debugar usando o visual studio code por exemplo:
 

https://www.youtube.com/watch?v=UH9iJcZjUes&ab_channel=hcode

 

Crie uma conta ou entre para comentar

Você precisa ser um usuário para fazer um comentário

Criar uma conta

Crie uma nova conta em nossa comunidade. É fácil!

Crie uma nova conta

Entrar

Já tem uma conta? Faça o login.

Entrar agora

Sobre o Clube do Hardware

No ar desde 1996, o Clube do Hardware é uma das maiores, mais antigas e mais respeitadas comunidades sobre tecnologia do Brasil. Leia mais

Direitos autorais

Não permitimos a cópia ou reprodução do conteúdo do nosso site, fórum, newsletters e redes sociais, mesmo citando-se a fonte. Leia mais

×
×
  • Criar novo...

LANÇAMENTO!

eletronica2025-popup.jpg


CLIQUE AQUI E BAIXE AGORA MESMO!