查看: 1080|回复: 1

[有事请教] 不知道为什么PIXI.AnimatedSprite Play()的时候一直报错

[复制链接]
梦石
0
星屑
3264
在线时间
777 小时
注册时间
2023-5-18
回帖
154
发表于 2024-2-2 22:45:37 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
我想播放一组图片,一共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是第一张图,以下是错误日志:
SharedScreenshot.jpg
SharedScreenshot2.jpg
B站:传送门
-----------------------------------------------------------------------
“与其为做不到的事耿耿于怀,不如为自己做到的事而喜悦
吧!”

-----------------------------------------------------------------------
梦石
0
星屑
3264
在线时间
777 小时
注册时间
2023-5-18
回帖
154
 楼主| 发表于 2024-2-2 22:46:39 | 显示全部楼层
有大佬知道这是为啥吗
B站:传送门
-----------------------------------------------------------------------
“与其为做不到的事耿耿于怀,不如为自己做到的事而喜悦
吧!”

-----------------------------------------------------------------------
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部