Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

185
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!