From 259ef96493c0b35d9067a8ff38d2c543708b7d8d Mon Sep 17 00:00:00 2001 From: Kyzentun Date: Tue, 13 Jan 2015 04:27:52 -0700 Subject: [PATCH] Reset sprite state when setting new state properties. --- src/Sprite.cpp | 4 ++++ src/Sprite.h | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Sprite.cpp b/src/Sprite.cpp index a165a0d60b..60a723c3e8 100644 --- a/src/Sprite.cpp +++ b/src/Sprite.cpp @@ -1127,6 +1127,10 @@ public: } vector new_states; size_t num_states= lua_objlen(L, 1); + if(num_states == 0) + { + luaL_error(L, "A Sprite cannot have zero states."); + } for(size_t s= 0; s < num_states; ++s) { Sprite::State new_state; diff --git a/src/Sprite.h b/src/Sprite.h index 6820b80f14..9c136b91f5 100644 --- a/src/Sprite.h +++ b/src/Sprite.h @@ -57,7 +57,7 @@ public: virtual float GetAnimationLengthSeconds() const; virtual void SetSecondsIntoAnimation( float fSeconds ); void SetStateProperties(const vector& new_states) - { m_States= new_states; } + { m_States= new_states; SetState(0); } RString GetTexturePath() const;