Jump to content
This forum will be closing down. Please move to the respective dedicated project forums.

can I convert a TilingSprite to Sprite2D?


alexzchen
 Share

Recommended Posts

hi, in recent days, I am following the website demo to learn the projection plugin, when I convert a TilingSprite to Sprite2D, it will cause an error(uvs is null), but Sprite is ok, is it a bug?

 

const app = new PIXI.Application({ backgroundColor: 0x1099bb });
document.body.appendChild(app.view);

const w = app.screen.width / 2; 
const h = app.screen.height / 2;

function createSquare(x, y) {
    const square = new PIXI.Sprite(PIXI.Texture.WHITE);    
    square.position.set(x, y);
    square.anchor.set(0.5);
    return square;
}

const squares = [
    createSquare(w - 150, h - 150),
    createSquare(w + 150, h - 150),
    createSquare(w + 150, h + 150),
    createSquare(w - 150, h + 150),
];

const quad = squares.map((s) => s.position);

const tilingSprite = PIXI.TilingSprite.from("examples/assets/flowerTop.png",200,200);
tilingSprite.anchor.set(0.5)
tilingSprite.convertTo2d();   //convertTo2d,tilingSpite throw an error, Spite is ok

app.stage.addChild(tilingSprite);
squares.forEach((s) => { app.stage.addChild(s); });
tilingSprite.proj.mapSprite(tilingSprite, quad);

 

123.png

Link to comment
Share on other sites

OK, lets see..

pixi-projection is experimental plugin, here: https://github.com/pixijs/pixi-projection .

Here's Sprite2d: https://github.com/pixijs/pixi-projection/blob/master/src/proj2d/tiling/TilingSprite2d.ts

Here's convertTo2d: https://github.com/pixijs/pixi-projection/blob/master/src/proj2d/sprites/convert.ts

Conclusion: its not a bug. Its just no one coded it.

it seems that there's no function there for TilingSprite, and I'm too lazy to implement it, you're the first one who needs TilingSprite to be converted, so you have three options:

1. dont use convertion

2. clone the repo, add the case into convertion, build it, use in your project. Maybe even make a PR.

3. wait if I make it .. next month maybe? I dont have much free coding time now for my 10 pixi plugins :)

 

Edited by ivan.popelyshev
Link to comment
Share on other sites

  • 6 months later...
  • 2 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...