Fix crash on calling play() in a uninitialized AnimatedSprite2D

When AnimatedSprite2D::play() was called before SpriteFrames has been initialized, a crach occurred (issue #46013).

Modification : An error message on null check test has been added to prevent crash.

Fix #46013.
This commit is contained in:
jmb462 2021-03-16 17:28:16 +01:00
parent bc7e105821
commit 324ab63844
1 changed files with 1 additions and 0 deletions

View File

@ -382,6 +382,7 @@ bool AnimatedSprite2D::_is_playing() const {
}
void AnimatedSprite2D::play(const StringName &p_animation, const bool p_backwards) {
ERR_FAIL_NULL_MSG(frames, "Can't play AnimatedSprite2D without a valid SpriteFrames resource.");
backwards = p_backwards;
if (p_animation) {