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

147
Views
How to get a sprite to scale in Phaser

I'm importing an image from a json spritesheet, which works okay, however I want to get the sprite to scale once it is in the game. Using the code below I get the error in console "Uncaught TypeError: plane.scale is not a function".

    const config = {
    type: Phaser.AUTO,
    width: 800,
    height: 600,
    scene: {
        preload: preload,
        create: create
        }
    };

    const game = new Phaser.Game(config);

    function preload () {
        this.load.image('background', 'assets/1.jpg');
        this.load.multiatlas('aircraft', 'assets/texture.json', 'assets');
    }

    function create () {
        const background = this.add.image(800, 600, 'background');
        const plane = this.add.sprite(200, 200, 'aircraft', 'Glider2.png');
        plane.scale(0.1, 0.1);
    }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The problem / error is caused, because the function you should use is setScale not scale (link to the documentation).

The code should look like this:

...
const plane = this.add.sprite(200, 200, 'aircraft', 'Glider2.png');
plane.setScale(0.1);
...

btw: if the scale is the same value on the x and the y axis you can omit the second parameter.

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!