Project1

标题: 不知道为什么PIXI.AnimatedSprite Play()的时候一直报错 [打印本页]

作者: Arrose    时间: 2024-2-2 22:45
标题: 不知道为什么PIXI.AnimatedSprite Play()的时候一直报错
我想播放一组图片,一共5张,然后我用了下面的代码:
[pre lang="JavaScript"]const _Create_Background = Scene_Title.prototype.createBackground;
    Scene_Title.prototype.createBackground = function() {
        _Create_Background.apply(this, arguments);
        const titleCommandButtonCursorSpriteTextureArray = [];
        for (const image of titleCommandButtonCursorSpriteJsonObject) {
            console.log("image: ", "img/" + image + ".png")
            let texture = PIXI.Texture.from("img/" + image + ".png");
            titleCommandButtonCursorSpriteTextureArray.push(texture);
        }

        // let animatedSprite = new PIXI.AnimatedSprite(titleCommandButtonCursorSpriteTextureArray, true);
        let animatedSprite = new PIXI.AnimatedSprite(titleCommandButtonCursorSpriteTextureArray);
        animatedSprite.animationSpeed = 1;
        animatedSprite.loop = true;
        animatedSprite.x = titleCommandButtonCursorSpriteRect.x;
        animatedSprite.y = titleCommandButtonCursorSpriteRect.y;
        animatedSprite.width = titleCommandButtonCursorSpriteRect.width;
        animatedSprite.height = titleCommandButtonCursorSpriteRect.height;
        animatedSprite.onComplete = () => {
            
        };
        animatedSprite.gotoAndPlay(0);
        console.log("animatedSprite: ", animatedSprite)
        this.addChild(animatedSprite);

    };[/pre]

titleCommandButtonCursorSpriteJsonObject是个图片路径字符串数组,titleCommandButtonCursorSpriteRect也是从插件参数传回来的,但是只要使用gotoAndPlay或者Play,animatedSprite._texture会变成undefined,就会出现"TypeError: Cannot read property '_uvs' of undefined"

不用gotoAndPlay或者Play,会固定正常显示第一张图,我还发现,这时候animatedSprite._texture是第一张图,以下是错误日志:

作者: Arrose    时间: 2024-2-2 22:46
有大佬知道这是为啥吗




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X5.0