@@ -1067,15 +1067,17 @@ PyObject* PythonModules::animated_sprite_play(PyObject *self, PyObject *args, Py
10671067 if (PyArg_ParseTupleAndKeywords (args, kwargs, " is" , animatedSpriteAnimationUpdateKWList, &entity, &pyAnimationName)) {
10681068 AnimatedSpriteComponent animatedSpriteComponent = entityComponentOrchestrator->GetComponent <AnimatedSpriteComponent>(entity);
10691069 const std::string &animationName = std::string (pyAnimationName);
1070- if (animationName.empty ()) {
1071- animatedSpriteComponent.isPlaying = true ;
1072- animatedSpriteComponent.startAnimationTickTime = SDL_GetTicks ();
1073- } else if (animatedSpriteComponent.animations .count (animationName) > 0 ) {
1074- animatedSpriteComponent.isPlaying = true ;
1075- animatedSpriteComponent.currentAnimation = animatedSpriteComponent.animations [animationName];
1076- animatedSpriteComponent.startAnimationTickTime = SDL_GetTicks ();
1070+ if (!animatedSpriteComponent.isPlaying || animatedSpriteComponent.currentAnimation .name != animationName) {
1071+ if (animationName.empty ()) {
1072+ animatedSpriteComponent.isPlaying = true ;
1073+ animatedSpriteComponent.startAnimationTickTime = SDL_GetTicks ();
1074+ } else if (animatedSpriteComponent.animations .count (animationName) > 0 ) {
1075+ animatedSpriteComponent.isPlaying = true ;
1076+ animatedSpriteComponent.currentAnimation = animatedSpriteComponent.animations [animationName];
1077+ animatedSpriteComponent.startAnimationTickTime = SDL_GetTicks ();
1078+ }
1079+ entityComponentOrchestrator->UpdateComponent <AnimatedSpriteComponent>(entity, animatedSpriteComponent);
10771080 }
1078- entityComponentOrchestrator->UpdateComponent <AnimatedSpriteComponent>(entity, animatedSpriteComponent);
10791081 Py_RETURN_NONE;
10801082 }
10811083 return nullptr ;
0 commit comments