设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 131|回复: 1
打印 上一主题 下一主题

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

[复制链接]

Lv3.寻梦者

梦石
0
星屑
1026
在线时间
202 小时
注册时间
2023-5-18
帖子
104
跳转到指定楼层
1
发表于 2024-2-2 22:45:37 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

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

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

x
我想播放一组图片,一共5张,然后我用了下面的代码:
JAVASCRIPT 代码复制
  1. const _Create_Background = Scene_Title.prototype.createBackground;
  2.     Scene_Title.prototype.createBackground = function() {
  3.         _Create_Background.apply(this, arguments);
  4.         const titleCommandButtonCursorSpriteTextureArray = [];
  5.         for (const image of titleCommandButtonCursorSpriteJsonObject) {
  6.             console.log("image: ", "img/" + image + ".png")
  7.             let texture = PIXI.Texture.from("img/" + image + ".png");
  8.             titleCommandButtonCursorSpriteTextureArray.push(texture);
  9.         }
  10.  
  11.         // let animatedSprite = new PIXI.AnimatedSprite(titleCommandButtonCursorSpriteTextureArray, true);
  12.         let animatedSprite = new PIXI.AnimatedSprite(titleCommandButtonCursorSpriteTextureArray);
  13.         animatedSprite.animationSpeed = 1;
  14.         animatedSprite.loop = true;
  15.         animatedSprite.x = titleCommandButtonCursorSpriteRect.x;
  16.         animatedSprite.y = titleCommandButtonCursorSpriteRect.y;
  17.         animatedSprite.width = titleCommandButtonCursorSpriteRect.width;
  18.         animatedSprite.height = titleCommandButtonCursorSpriteRect.height;
  19.         animatedSprite.onComplete = () => {
  20.  
  21.         };
  22.         animatedSprite.gotoAndPlay(0);
  23.         console.log("animatedSprite: ", animatedSprite)
  24.         this.addChild(animatedSprite);
  25.  
  26.     };


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

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

SharedScreenshot.jpg (160.26 KB, 下载次数: 3)

SharedScreenshot.jpg

SharedScreenshot2.jpg (86.25 KB, 下载次数: 0)

SharedScreenshot2.jpg
我的B站传送门

Lv3.寻梦者

梦石
0
星屑
1026
在线时间
202 小时
注册时间
2023-5-18
帖子
104
2
 楼主| 发表于 2024-2-2 22:46:39 | 只看该作者
有大佬知道这是为啥吗
我的B站传送门
回复 支持 反对

使用道具 举报

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

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-4-28 13:42

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表