moJoe

Villager
Member
Joined
Mar 10, 2021
Messages
5
Reaction score
1
First Language
English
Primarily Uses
RMMV
Yo!

I am trying to add an animated svbattler to the menu screen but have only managed to add a non animated sprite. I have looked into "SRD_AltMenuScreen_BustSelect" to try and reverse engineer and see how he did it but.. I am a beginner at coding and it may take me weeks to fully understand what's going on there. I know it has been done before but I am trying to look at a simpler code to understand the process.

I am requesting a simplified code that will do just that: add a animated svbattler to the menu screen, positioning and which battler doesnt matter for now.

My current understanding as to why my sprite wont animate is because opening the menu stops the map animations. So a custom frame counter needs to be created in order to update the sprite into animation. I have a feeling I am way off the mark here.

help! :)

JavaScript:
function Scene_CustomMenu() {
    this.initialize.apply(this, arguments);
}

Scene_CustomMenu.prototype = Object.create(Scene_Menu.prototype);
Scene_CustomMenu.prototype.constructor = Scene_CustomMenu;

Scene_CustomMenu.prototype.create = function () {
    Scene_Menu.prototype.create.call(this);
    this.createSVBattler();
};

Scene_CustomMenu.prototype.createSVBattler = function() {
    this._spriteActors = new Sprite_CustomActor(this.actor());
    this.addChild(this._spriteActors);
};

function Sprite_CustomActor() {
    this.initialize.apply(this, arguments);
}

Sprite_CustomActor.prototype = Object.create(Sprite_Actor.prototype);
Sprite_CustomActor.prototype.constructor = Sprite_CustomActor;

Sprite_CustomActor.prototype.setActorHome = function(index) {
    this.setHome(670, 290);
};
 

moJoe

Villager
Member
Joined
Mar 10, 2021
Messages
5
Reaction score
1
First Language
English
Primarily Uses
RMMV
I managed to reverse engineer SRDudes svbattler but it only worked by putting the svbattler animation over a window(to my beginner understanding, im not sure if im right here). So yesterday I took another look at possibilities and found out about PIXI and the issue with PIXI.extras.AnimatedSprite.

Long story short here's a script that does exactly what I want if I call it on the F8 screen ( createSVBattler() ). I'm sure there's a better way to write the script, to shorten it and/or tailor it to whatever you want. Personally I'm gonna' edit the script to add a svbattler animation to the menu and equip scenes. Anyway:

JavaScript:
function createSVBattler() {
    let actor = $gameParty.menuActor();
    let img = new Image();
    img.src = 'img/sv_actors/' + actor.battlerName() + '.png';
    let ssheet = new PIXI.BaseTexture(img);
    let w = 64
    let idleanimated0 = new PIXI.Texture(ssheet, new PIXI.Rectangle(0 , 0, w, w));
    let idleanimated1 = new PIXI.Texture(ssheet, new PIXI.Rectangle(1 * w, 0, w, w));
    let idleanimated2 = new PIXI.Texture(ssheet, new PIXI.Rectangle(2 * w, 0, w, w));
    let idleanimated3 = new PIXI.Texture(ssheet, new PIXI.Rectangle(1 * w, 0, w, w));
    let playerSheet = [];
    playerSheet.push(idleanimated0);
    playerSheet.push(idleanimated1);
    playerSheet.push(idleanimated2);
    playerSheet.push(idleanimated3);
    let container = new PIXI.Container();
    let player = new PIXI.extras.AnimatedSprite(playerSheet);
    container.addChild(player);
    container.update = function (detla=1) {
        player.update(detla);
    };
    player.anchor.set(0.5);
    player.animationSpeed = .07;
    player.x = 400;
    player.y = 400;
    SceneManager._scene.addChild(container);
};

Low and behold rpgmaker forums came through; helpful community already found and fixed the bug with PIXI animated sprites. Thanks! :)
 

Latest Threads

Latest Posts

Latest Profile Posts

Tired of just doing mobile. Now you can Play the game in ur Browser! https://bigmala-productions.itch.io/rpg-forever
I managed to fix my car at last... :biggrin:

I'm proud of what I have achieved with my project. Don't mind with the Spanish, Ill add more languages.
Our garage has been so full since moving we haven't been able to get our car in. Storm night before last (no hail), storms forecast for last night & today. I convinced hubby we should clean out the garage and we managed to get it done and get the car in. Hail last night! Just in time!

Forum statistics

Threads
111,279
Messages
1,059,851
Members
144,581
Latest member
RaijinDeity
Top