From 66da19552ea855d825c6a68b00e3e5ea8b84d932 Mon Sep 17 00:00:00 2001 From: Sylvain Dupont Date: Tue, 26 Oct 2010 22:18:14 +0000 Subject: TOON: Implement cmd_Set_Anim_Scale_Size Used to rescale the knight animation when the knight is moved around the room in Chapter 2 svn-id: r53865 --- engines/toon/anim.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'engines/toon/anim.cpp') diff --git a/engines/toon/anim.cpp b/engines/toon/anim.cpp index be53c12dc7..c5769f5081 100644 --- a/engines/toon/anim.cpp +++ b/engines/toon/anim.cpp @@ -425,6 +425,7 @@ AnimationInstance::AnimationInstance(ToonEngine *vm, AnimationInstanceType type) _playing = false; _rangeEnd = 0; _useMask = false; + _alignBottom = false; _rangeStart = 0; _scale = 1024; _x = 0; @@ -433,6 +434,7 @@ AnimationInstance::AnimationInstance(ToonEngine *vm, AnimationInstanceType type) _layerZ = 0; } + void AnimationInstance::render() { debugC(5, kDebugAnim, "render()"); if (_visible && _animation) { @@ -443,11 +445,22 @@ void AnimationInstance::render() { if (frame >= _animation->_numFrames) frame = _animation->_numFrames - 1; + int32 x = _x; + int32 y = _y; + + if (_alignBottom) { + int32 offsetX = (_animation->_x2 - _animation->_x1) / 2 * (_scale - 1024); + int32 offsetY = (_animation->_y2 - _animation->_y1) * (_scale - 1024); + + x -= offsetX >> 10; + y -= offsetY >> 10; + } + if (_useMask) { //if (_scale == 100) { // 100% scale // _animation->drawFrameWithMask(_vm->getMainSurface(), _currentFrame, _x, _y, _z, _vm->getMask()); //} else { - _animation->drawFrameWithMaskAndScale(_vm->getMainSurface(), frame, _x, _y, _z, _vm->getMask(), _scale); + _animation->drawFrameWithMaskAndScale(_vm->getMainSurface(), frame, x, y, _z, _vm->getMask(), _scale); //} } else { _animation->drawFrame(_vm->getMainSurface(), frame, _x, _y); @@ -534,9 +547,10 @@ void AnimationInstance::setVisible(bool visible) { _visible = visible; } -void AnimationInstance::setScale(int32 scale) { +void AnimationInstance::setScale(int32 scale, bool align) { debugC(4, kDebugAnim, "setScale(%d)", scale); _scale = scale; + _alignBottom = align; } void AnimationInstance::setUseMask(bool useMask) { -- cgit v1.2.3