void as::AnimatedSprite::tick( sf::Time deltaTime ) { // if paused or we have less than one frame to display on the current animation. if ( m_paused || m_currentAnimation->m_frames.size() <= 1 ) { return; } m_currentTime += deltaTime; updateFrameIndex(); updateFrame(); }
void AnimatedSprite::updateAnim() { _frameChanged = false; if (_newAnimFileHash == 0) { if (_newStickFrameIndex != -1) { _currStickFrameIndex = _newStickFrameIndex == STICK_LAST_FRAME ? _animResource.getFrameCount() - 1 : _newStickFrameIndex; _newStickFrameIndex = -1; } else if (_newStickFrameHash != 0) { _currStickFrameIndex = MAX<int16>(0, _animResource.getFrameIndex(_newStickFrameHash)); _newStickFrameHash = 0; } if (_newAnimFileHash == 0 && _currFrameIndex != _currStickFrameIndex) { if (_currFrameTicks != 0 && (--_currFrameTicks == 0) && _animResource.getFrameCount() != 0) { if (_nextAnimFileHash != 0) { if (_animResource.load(_nextAnimFileHash)) { _currAnimFileHash = _nextAnimFileHash; } else { _animResource.load(calcHash("sqDefault")); _currAnimFileHash = 0; } if (_replOldColor != _replNewColor) { _animResource.setRepl(_replOldColor, _replNewColor); } _nextAnimFileHash = 0; if (_animStatus != 0) { _currFrameIndex = _plFirstFrameHash != 0 ? MAX<int16>(0, _animResource.getFrameIndex(_plFirstFrameHash)) : 0; _lastFrameIndex = _plLastFrameHash != 0 ? MAX<int16>(0, _animResource.getFrameIndex(_plLastFrameHash)) : _animResource.getFrameCount() - 1; } else { _currFrameIndex = _plFirstFrameIndex != -1 ? _plFirstFrameIndex : _animResource.getFrameCount() - 1; _lastFrameIndex = _plLastFrameIndex != -1 ? _plLastFrameIndex : _animResource.getFrameCount() - 1; } } else { updateFrameIndex(); } if (_newAnimFileHash == 0) updateFrameInfo(); } } } if (_newAnimFileHash != 0) { if (_animStatus == 2) { _currStickFrameIndex = _currFrameIndex; } else { if (_animStatus == 1) { if (_animResource.load(_newAnimFileHash)) { _currAnimFileHash = _newAnimFileHash; } else { _animResource.load(calcHash("sqDefault")); _currAnimFileHash = 0; } if (_replOldColor != _replNewColor) { _animResource.setRepl(_replOldColor, _replNewColor); } _newAnimFileHash = 0; _currFrameIndex = _plFirstFrameHash != 0 ? MAX<int16>(0, _animResource.getFrameIndex(_plFirstFrameHash)) : 0; _lastFrameIndex = _plLastFrameHash != 0 ? MAX<int16>(0, _animResource.getFrameIndex(_plLastFrameHash)) : _animResource.getFrameCount() - 1; } else { if (_animResource.load(_newAnimFileHash)) { _currAnimFileHash = _newAnimFileHash; } else { _animResource.load(calcHash("sqDefault")); _currAnimFileHash = 0; } if (_replOldColor != _replNewColor) { _animResource.setRepl(_replOldColor, _replNewColor); } _newAnimFileHash = 0; _currFrameIndex = _plFirstFrameIndex != -1 ? _plFirstFrameIndex : _animResource.getFrameCount() - 1; _lastFrameIndex = _plLastFrameIndex != -1 ? _plLastFrameIndex : _animResource.getFrameCount() - 1; } updateFrameInfo(); } if (_newStickFrameIndex != -1) { _currStickFrameIndex = _newStickFrameIndex == STICK_LAST_FRAME ? _animResource.getFrameCount() - 1 : _newStickFrameIndex; _newStickFrameIndex = -1; } else if (_newStickFrameHash != 0) { _currStickFrameIndex = MAX<int16>(0, _animResource.getFrameIndex(_newStickFrameHash)); _newStickFrameHash = 0; } } }