diff --git a/core/Transition/Transition.cpp b/core/Transition/Transition.cpp index afdc35a3..bd3298af 100644 --- a/core/Transition/Transition.cpp +++ b/core/Transition/Transition.cpp @@ -100,7 +100,6 @@ void e2d::Transition::_render() pRT->PushAxisAlignedClip(clipRect, D2D1_ANTIALIAS_MODE_PER_PRIMITIVE); pRT->PushLayer(_outLayerParam, _outLayer); - // 渲染场景 _outScene->_render(); pRT->PopLayer(); @@ -120,7 +119,6 @@ void e2d::Transition::_render() pRT->PushAxisAlignedClip(clipRect, D2D1_ANTIALIAS_MODE_PER_PRIMITIVE); pRT->PushLayer(_inLayerParam, _inLayer); - // 渲染场景 _inScene->_render(); pRT->PopLayer(); diff --git a/core/Transition/TransitionBox.cpp b/core/Transition/TransitionBox.cpp new file mode 100644 index 00000000..24580b38 --- /dev/null +++ b/core/Transition/TransitionBox.cpp @@ -0,0 +1,45 @@ +#include "..\e2dtransition.h" +#include "..\e2dnode.h" + +e2d::TransitionBox::TransitionBox(double duration) + : Transition(duration) +{ +} + +void e2d::TransitionBox::_init(Scene * prev, Scene * next) +{ + Transition::_init(prev, next); + _inLayerParam.opacity = 0; +} + +void e2d::TransitionBox::_updateCustom() +{ + if (_delta <= 0.5) + { + _outLayerParam.contentBounds = D2D1::RectF( + float(_windowSize.width * _delta), + float(_windowSize.height * _delta), + float(_windowSize.width * (1 - _delta)), + float(_windowSize.height * (1 - _delta)) + ); + } + else + { + _outLayerParam.opacity = 0; + _inLayerParam.opacity = 1; + _inLayerParam.contentBounds = D2D1::RectF( + float(_windowSize.width * (1 - _delta)), + float(_windowSize.height * (1 - _delta)), + float(_windowSize.width * _delta), + float(_windowSize.height * _delta) + ); + if (_delta >= 1) + { + this->_stop(); + } + } +} + +void e2d::TransitionBox::_reset() +{ +} diff --git a/core/e2dtransition.h b/core/e2dtransition.h index 5cdc70c5..9dd40c26 100644 --- a/core/e2dtransition.h +++ b/core/e2dtransition.h @@ -62,7 +62,7 @@ protected: }; -// 渐变过渡 +// 淡入淡出过渡 class TransitionFade : public Transition { @@ -84,6 +84,7 @@ protected: }; +// 渐变过渡 class TransitionEmerge : public Transition { @@ -105,6 +106,29 @@ protected: }; +// 盒状过渡 +class TransitionBox : + public Transition +{ +public: + TransitionBox( + double duration /* 动画持续时长 */ + ); + +protected: + // 更新动画 + virtual void _updateCustom() override; + + virtual void _init( + Scene * prev, + Scene * next + ) override; + + virtual void _reset() override; +}; + + +// 移入过渡 class TransitionMove : public Transition { diff --git a/project/vs2017/Easy2D.vcxproj b/project/vs2017/Easy2D.vcxproj index c7846384..42904b75 100644 --- a/project/vs2017/Easy2D.vcxproj +++ b/project/vs2017/Easy2D.vcxproj @@ -258,6 +258,7 @@ + diff --git a/project/vs2017/Easy2D.vcxproj.filters b/project/vs2017/Easy2D.vcxproj.filters index e8ce7e26..ffa19d4d 100644 --- a/project/vs2017/Easy2D.vcxproj.filters +++ b/project/vs2017/Easy2D.vcxproj.filters @@ -228,6 +228,9 @@ Custom + + Transition +