You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Issue :
This function uses Static variables for frameRateCounter and currentFrame counting which makes this is ideal if is being used to animate a single sprite sheet with the intention of avoiding global variables, but the static variables values get overwritten/ influenced if the function is called multiple times to animate other sprites sheets/ Different Textures making this function Non-Generic, also using global variables for frame and rate counting for 100's of sprites sheets would be absurd.
Desired Solution:
It is necessary to make this function more Generic by making it retain certain values (for now 2 variables for rate and frameCount) separately for each instance call if new Texture is passed to is. So for every new texture how many ever times it may be called it must retain a few variables, i.e must have local static variables for every new texture passed.
Current Workaround:
If using this function to animate different instances of same Texture multiply the base frameSpeed by number of instances to get the same effect as if using a single texture.
This is same as increasing frame speed delay proportional to increased number of function calls.
The text was updated successfully, but these errors were encountered:
Proposed solution 1 :
However the current workaround is not a generic solution because similar textures will function properly for the same frame speed but different textures require different frame speeds, however we can use a algorithm to set the frame rate dynamically for every frame call that can interpolate all the frame rates.
void AnimateSpriteSheetRec(Texture2D spriteSheet, Rectangle *frameRec, int framesSpeed, int frames);
Implementation Code :
Issue :
This function uses Static variables for frameRateCounter and currentFrame counting which makes this is ideal if is being used to animate a single sprite sheet with the intention of avoiding global variables, but the static variables values get overwritten/ influenced if the function is called multiple times to animate other sprites sheets/ Different Textures making this function Non-Generic, also using global variables for frame and rate counting for 100's of sprites sheets would be absurd.
Desired Solution:
It is necessary to make this function more Generic by making it retain certain values (for now 2 variables for rate and frameCount) separately for each instance call if new Texture is passed to is. So for every new texture how many ever times it may be called it must retain a few variables, i.e must have local static variables for every new texture passed.
Current Workaround:
The text was updated successfully, but these errors were encountered: