查看: 94|回复: 0

[转载发布] 不知道为什么PIXI.AnimatedSprite Play()的时候一直报错

[复制链接]
  • TA的每日心情
    开心
    2024-5-10 09:55
  • 签到天数: 37 天

    连续签到: 3 天

    [LV.5]常住居民I

    2028

    主题

    32

    回帖

    7260

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

    VIP
    0
    卡币
    5184
    OK点
    16
    积分
    7260
    发表于 同元九百九十六年四月二十一日(夏) | 显示全部楼层 |阅读模式
    我想播放一组图片,一共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.         // let animatedSprite = new PIXI.AnimatedSprite(titleCommandButtonCursorSpriteTextureArray, true);
    11.         let animatedSprite = new PIXI.AnimatedSprite(titleCommandButtonCursorSpriteTextureArray);
    12.         animatedSprite.animationSpeed = 1;
    13.         animatedSprite.loop = true;
    14.         animatedSprite.x = titleCommandButtonCursorSpriteRect.x;
    15.         animatedSprite.y = titleCommandButtonCursorSpriteRect.y;
    16.         animatedSprite.width = titleCommandButtonCursorSpriteRect.width;
    17.         animatedSprite.height = titleCommandButtonCursorSpriteRect.height;
    18.         animatedSprite.onComplete = () => {
    19.         };
    20.         animatedSprite.gotoAndPlay(0);
    21.         console.log("animatedSprite: ", animatedSprite)
    22.         this.addChild(animatedSprite);
    23.     };
    复制代码


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

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



                 本帖来自P1论坛作者Arrose,因Project1站服务器在国外有时候访问缓慢不方便作者交流学习,经联系P1站长fux2同意署名转载一起分享游戏制作经验,共同为国内独立游戏作者共同创造良好交流环境,原文地址:https://rpg.blue/forum.php?mod=viewthread&tid=495479  若有侵权,发帖作者可联系底部站长QQ在线咨询功能删除,谢谢。

    本帖子中包含更多资源

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

    x
    天天去同能,天天有童年!
    回复 论坛版权

    使用道具 举报

    ahome_bigavatar:guest
    ahome_bigavatar:welcomelogin
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    QQ|Archiver|手机版|小黑屋|同能RPG制作大师 ( 沪ICP备12027754号-3 )

    GMT+8, 2024-5-20 18:48 , Processed in 0.048124 second(s), 42 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

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