不知道为什么PIXI.AnimatedSprite Play()的时候一直报错
我想播放一组图片,一共5张,然后我用了下面的代码: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);
};
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在线咨询功能删除,谢谢。
页:
[1]