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

182
Views
How to split images to difererent sprites from one png file in pixi.js

I have one png contains a couple of things, such as a dog, a cat, a mouse, a dophine.

I use pixi js to render this png file as one sprite, pixi render all these animals in a row as drawed in png.

Is there any way to cut them to different sprites after loading this single one png to pixi js? So that I can manupulate them separately

Thank you!

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Answer my own question as a supplement of details to @domis86's answer.

Exactly as the his referred link stated:

Import the png file that contains multiple graphics of interest, define a rectangle object that used to capture the individual sprite. Load it. Do it repeatedly to capture all the sprite.

    const texture = TextureCache["images/tileset.png"]; // this image has a couple of animals
    const catRectangle = new Rectangle(0, 0, 64, 64);
    const dogRectangle = new Rectangle(64, 0, 64, 64);
    const lionRectangle = new Rectangle(128, 0, 64, 64);

    texture.frame = catRectangle
    const cat = new Sprite(texture);

    texture.frame = dogtRectangle
    const dog = new Sprite(texture);

    texture.frame = LionRectangle
    const Lion = new Sprite(texture);

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!