Jump to content

Pixi text does not update when there's another pixi text with the same text


Hanxol
 Share

Recommended Posts

Hi!

When you change the text of a PIXI.Text to the same that another PIXI.Text already has it does not change the text, it keeps the old value. Or at least when it has the same amount of characters, it works fine when changing from 9 to 10 wwhen the first number is 10.
The thing is... that if you change any parameter of the style it seems to work fine, I left a line with the change of the color, also tried with the size of the font.

Looks like it updates the text, at least in the pixi devtools it shows the actual text, also it updates the size of the text width, since you can see the width of the right number getting smaller when trying to change from "10" to "11".

 

I will leave this PixiPlayground code, if you uncomment the line 21 you can see how it should actually work:
https://www.pixiplayground.com/#/edit/zDPUvOSrNZ9Z1qWQ98O_C

 

I'll leave the code anyways just in case:

/**
* This is the default playground.
* You should see a bunny spinning in the right preview pane.
* Feel free to use this as a starting point for you own playground!
*/
var text1;
var text2;
// Create our application instance
(async () => {
    const app = new PIXI.Application();
    await app.init({
        width: window.innerWidth,
        height: window.innerHeight,
        backgroundColor: 0x2c3e50
    })
    document.body.appendChild(app.canvas);

    text1 = new PIXI.Text();
    text1.text = "8";
    text1.style = {fontSize: 100};
    //text1.style = {fill: "#fff", fontSize: 100}; // <--- comment this line to see how it should actually work
    app.stage.addChild(text1);


    text2 = new PIXI.Text();
    text2.text = "8";
    text2.position.set(250, 0);
    text2.style = {fontSize: 100};
    app.stage.addChild(text2);

    function asd(aux) {
        aux.text = (parseInt(aux.text) + 1).toString();
    }

    setInterval(()=> {
        asd(parseInt(text1.text) > parseInt(text2.text) ? text2 : text1);
    }, 500);


})();

 

Link to comment
Share on other sites

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...