Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

187
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda