Open soulweaver91 opened 9 years ago
Other than that level load time resource retrieval, the applicable animation states in the manifests should also be migrated off the arbitrary number values to something more legible. (for example: "states": ["jump shoot", "fall shoot", "jump walk shoot"]
)
This still seems quite troublesome after putting a lot of thought and trying a failed code experiment. Some pointers:
AnimStateT
should be scrapped completely. Anything that uses that type should convert to using identifier QString
s. (This is because they cannot be used in a meaningful way inside the manifest JSON files.)AnimationUser
already has a function for setting the animation by the string key unique to an animation. This should be changed to accept either those keys or a key from any animation's states
.AnimationUser
s having a currentAnimation
and currentTransition
with the latter having more options (cancellable, callback once finished), these should be combined instead. Theoretical API could be
bool setAnimation(const QString& key, bool repeat = true, bool cancellable = true, AnimationCallbackFunc cb = []() { });
bool setAnimation(std::shared_ptr<GraphicResource> animation, bool repeat = true, bool cancellable = true, AnimationCallbackFunc cb = []() { });
CommonActor
's overridden function could probably be simplified and replaced with one that just passes parameters forward to AnimationUser
's function and runs updateHitbox()
if it returned true
. The transition stuff doesn't really have any reason to be there, it's pretty much Player
specific.Note: the last point of the previous comment was mostly dealt with in one of the collision revamp commits.
Currently, each actor manages its own graphic assets individually. Objects of same class read the same assets multiple times in memory, which is obviously a very bad idea.
To fix this, implement a graphics cache: once a level starts, find all objects that have been used and call a static graphics bootstrapping static method on each. Load one copy of each sprite at most even if it was requested from multiple different objects. Keep the sprites in memory until the end of level or end of game. The object constructors need to be adapted to this.
Also, while changing the way the graphics are loaded, externalize the previously hardcoded values from the code to data files (XML or equivalent).