RMMV requestAnimation() unable to perform anime completely

henryandjay

Villager
Member
Joined
Jun 17, 2019
Messages
10
Reaction score
3
First Language
Chinese
Primarily Uses
RMMV
Hi all:

I am developing a game that the combat is directly performed on map. The player can see attack anime affect and damage, like the following image:
rpg_capture.png

Therefore, I got used of requestAnimation() function.
At the beginning, the animation works just fine, anime & sound effect can be performed entirely, which took about maybe 0.5 seconds to finish. However, due to a requirement that enemy movement phase may have to wait until another event finish, I refactor the mechanism to be asynchronous, using setTimeout() and function state, for pseudo code example:

Code:
toExecute = function() {
    let func = toExecute, waiting = 0;
    if (need to wait) {
        waiting = 50;
    } else {
        switch (global state) {
        case 0:
            // do something
            state = 1;
            break;
        case 1:
            // do something, state change to 2 if meet requirement
            xx.requestAnimation(yy);
            break;
        case 2:
            // return when meet condition, otherwise back to state 0
        }
    }
    setTimeout(func, waiting);
}
After the refactoring, game logic still works, but the animation will only remain very short time (maybe about 0.1 seconds), which makes both anime & sound effect seriously incomplete. In fact, sometimes the anime even not showed up.

I want to make the animation duration complete, also understanding what's happening. Can anyone help me with this?

BRs,
yuchieh
 
Last edited:

slimmmeiske2

Little Red Riding Hood
Global Mod
Joined
Sep 6, 2012
Messages
7,787
Reaction score
5,209
First Language
Dutch
Primarily Uses
RMXP

I've moved this thread to Learn Javascript. Please be sure to post your threads in the correct forum next time. Thank you.

 

henryandjay

Villager
Member
Joined
Jun 17, 2019
Messages
10
Reaction score
3
First Language
Chinese
Primarily Uses
RMMV
Really need help, any suggestions are welcomed!
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Just finished composing a boss battle theme!
Scripted a multi-variable weather system that randomizes wind speed, cloudiness, rain, fogginess, etc, while attempting to realistically account for interactions between them (e.g. wind speed affects fogginess, cloudiness affects rain, etc), the current weather pattern, and the player's biome e.g. swamp, beach, etc. Now I "just" have to tie visuals and sounds to the variables so stuff actually happens...
I'm having a headache balancing the combat using flat defense so I'm gonna use percentual armor, in this pic, Simon has 16 on Defense which means all the incoming damage will be reduced by 16% this will ease my burden a bit.
!Have a nice day everybody¡
SO glad they patched outer worlds for switch! I can finally play it! Weird that other peeps are still having issues. I know it was really chugging on my lite when it first came out.

Forum statistics

Threads
105,555
Messages
1,014,623
Members
137,231
Latest member
anjing_gila
Top