Hello, everyone. I'm trying to play a set of images, I used the following code:
If I don't use play() or gotoAndPlay(), the first image is displayed normally. I'm very new to pixi.js and I don't know what's happening with it. Here is my error log:
If play() is used, _texture will be undefined, otherwise _texture will be the first image. I don't know why I can't use play(), I've searched the internet for a long time but couldn't find an answer, does anyone know what's going on? Any advice is appreciated!
JavaScript:
const _Create_Background = Scene_Title.prototype.createBackground;
Scene_Title.prototype.createBackground = function() {
_Create_Background.apply(this, arguments);
const titleCommandButtonCursorSpriteTextureArray = [];
//titleCommandButtonCursorSpriteRect and titleCommandButtonCursorSpriteJsonObject is obtained from the plugin parameter
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);
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);
};
If play() is used, _texture will be undefined, otherwise _texture will be the first image. I don't know why I can't use play(), I've searched the internet for a long time but couldn't find an answer, does anyone know what's going on? Any advice is appreciated!