Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

193
Vistas
The program says "setVisible(false)" is not a function, why is this problem?

Im making a program in Phaser in JavaScript and im using the statement questions.setVisible(false) in my program, but this appears - Uncaught TypeError: question.setVisible is not a function, which clearly is. The statement is in the create function, it doesn't work in the other functions either. Code:

var Game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', {create})

var question;

function create() {
    question = Game.add.text(Game.width/2, Game.height/2, 'On which day is Pi celebrated?', {align: 'center'}).anchor.setTo(0.5);
    question.setVisible(false);
}
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I would recommend to use phaser 3, not phaser 2/CE/... or so. Since the most documentations and informations are for phaser 3. That said, it seems to me, that your problem is two fold:

  1. you cannot chain the all the properties/methods like this, as the comments mention it returns a different object. You would have to do this:

    // like this `question` is a Text object
    question = game.add.text(game.width/2,game.height/2, 'On which day is Pi celebrated?', {align: 'center', stroke:'white', fill:'white'});
    
    // set the anchor of the `question`
    question.anchor.setTo(0.5);
    
  2. the function setVisible doesn't exist for the text class. (atleast it is not mentioned in the documentation, side note: in phaser3 this function exists). For phaser 2/CE you would have to set the property visible:

    question.visible  = false;
    

So the whole function should look something like this:

    function create() {
        question = game.add.text(game.width/2,game.height/2, '...', {align: 'center'});
        question.anchor.setTo(0.5);
        question.visible  = false;
    }
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda