Code: Select all
if self.isStanding then self.sprite = sprite.standing elseif self.isWalking then self.sprite = sprite.walking self.sprite:update(dt) --probably an easy way to have this not trigger on the first frame you play, but that's not important for this example elseif self.isDucking then self.sprite = sprite.ducking end
My question is, is there anything significantly wrong with doing it this way? I feel like it's fairly obvious, but I've never seen anyone use it. It's obviously not as efficient as just setting it one time, coupled with the player's behavior, but does testing a few conditions every frame really affect performance that much, in practice? I'm pretty clueless when it comes to performance, so I'd appreciate any feedback.