[deploy] Merge pull request #26 from Nomango/dev
remove Geometry class and add ShapeNode to draw primitive shapes
|
|
@ -18,8 +18,7 @@
|
|||
<ClInclude Include="..\src\kiwano\2d\DebugNode.h" />
|
||||
<ClInclude Include="..\src\kiwano\2d\Font.hpp" />
|
||||
<ClInclude Include="..\src\kiwano\2d\Frames.h" />
|
||||
<ClInclude Include="..\src\kiwano\2d\Geometry.h" />
|
||||
<ClInclude Include="..\src\kiwano\2d\GeometryNode.h" />
|
||||
<ClInclude Include="..\src\kiwano\2d\ShapeNode.h" />
|
||||
<ClInclude Include="..\src\kiwano\2d\GifImage.h" />
|
||||
<ClInclude Include="..\src\kiwano\2d\Image.h" />
|
||||
<ClInclude Include="..\src\kiwano\2d\Layer.h" />
|
||||
|
|
@ -92,8 +91,7 @@
|
|||
<ClCompile Include="..\src\kiwano\2d\Color.cpp" />
|
||||
<ClCompile Include="..\src\kiwano\2d\DebugNode.cpp" />
|
||||
<ClCompile Include="..\src\kiwano\2d\Frames.cpp" />
|
||||
<ClCompile Include="..\src\kiwano\2d\Geometry.cpp" />
|
||||
<ClCompile Include="..\src\kiwano\2d\GeometryNode.cpp" />
|
||||
<ClCompile Include="..\src\kiwano\2d\ShapeNode.cpp" />
|
||||
<ClCompile Include="..\src\kiwano\2d\GifImage.cpp" />
|
||||
<ClCompile Include="..\src\kiwano\2d\GifSprite.cpp" />
|
||||
<ClCompile Include="..\src\kiwano\2d\Image.cpp" />
|
||||
|
|
|
|||
|
|
@ -36,133 +36,373 @@
|
|||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\src\kiwano\2d\GifSprite.h" />
|
||||
<ClInclude Include="..\src\kiwano\base\types.h" />
|
||||
<ClInclude Include="..\src\kiwano\kiwano.h" />
|
||||
<ClInclude Include="..\src\kiwano\ui\Button.h">
|
||||
<Filter>ui</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\kiwano\ui\Menu.h">
|
||||
<Filter>ui</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\kiwano\2d\Action.h">
|
||||
<Filter>2d</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\kiwano\2d\ActionGroup.h">
|
||||
<Filter>2d</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\kiwano\2d\ActionHelper.h">
|
||||
<Filter>2d</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\kiwano\2d\ActionManager.h">
|
||||
<Filter>2d</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\kiwano\2d\ActionTween.h">
|
||||
<Filter>2d</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\kiwano\2d\Animation.h">
|
||||
<Filter>2d</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\kiwano\2d\Canvas.h">
|
||||
<Filter>2d</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\kiwano\2d\Color.h">
|
||||
<Filter>2d</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\kiwano\2d\DebugNode.h">
|
||||
<Filter>2d</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\kiwano\2d\Font.hpp">
|
||||
<Filter>2d</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\kiwano\2d\Frames.h">
|
||||
<Filter>2d</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\kiwano\2d\Image.h">
|
||||
<Filter>2d</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\kiwano\2d\include-forwards.h">
|
||||
<Filter>2d</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\kiwano\2d\Layer.h">
|
||||
<Filter>2d</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\kiwano\2d\Node.h">
|
||||
<Filter>2d</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\kiwano\2d\Scene.h">
|
||||
<Filter>2d</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\kiwano\2d\Sprite.h">
|
||||
<Filter>2d</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\kiwano\2d\Text.h">
|
||||
<Filter>2d</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\kiwano\2d\TextStyle.hpp">
|
||||
<Filter>2d</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\kiwano\2d\Transform.hpp">
|
||||
<Filter>2d</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\kiwano\2d\Transition.h">
|
||||
<Filter>2d</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\kiwano\common\ComPtr.hpp">
|
||||
<Filter>common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\kiwano\common\helper.h">
|
||||
<Filter>common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\kiwano\common\IntrusiveList.hpp">
|
||||
<Filter>common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\kiwano\common\IntrusivePtr.hpp">
|
||||
<Filter>common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\kiwano\common\Singleton.hpp">
|
||||
<Filter>common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\kiwano\base\Component.h">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\kiwano\base\Event.hpp">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\kiwano\base\EventDispatcher.h">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\kiwano\base\EventListener.h">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\kiwano\base\keys.hpp">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\kiwano\base\logs.h">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\kiwano\base\RefCounter.hpp">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\kiwano\base\Resource.h">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\kiwano\base\time.h">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\kiwano\renderer\D2DDeviceResources.h">
|
||||
<Filter>renderer</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\kiwano\renderer\D3D10DeviceResources.h">
|
||||
<Filter>renderer</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\kiwano\renderer\D3D11DeviceResources.h">
|
||||
<Filter>renderer</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\kiwano\renderer\helper.hpp">
|
||||
<Filter>renderer</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\kiwano\renderer\render.h">
|
||||
<Filter>renderer</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\kiwano\renderer\TextRenderer.h">
|
||||
<Filter>renderer</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\kiwano\math\constants.hpp">
|
||||
<Filter>math</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\kiwano\math\ease.hpp">
|
||||
<Filter>math</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\kiwano\math\Matrix.hpp">
|
||||
<Filter>math</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\kiwano\math\rand.h">
|
||||
<Filter>math</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\kiwano\math\Rect.hpp">
|
||||
<Filter>math</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\kiwano\math\scalar.hpp">
|
||||
<Filter>math</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\kiwano\platform\Application.h">
|
||||
<Filter>platform</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\kiwano\platform\modules.h">
|
||||
<Filter>platform</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\kiwano\utils\Path.h">
|
||||
<Filter>utils</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\kiwano\utils\ResLoader.h">
|
||||
<Filter>utils</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\kiwano\config.h" />
|
||||
<ClInclude Include="..\src\kiwano\macros.h" />
|
||||
<ClInclude Include="..\src\kiwano\2d\include-forwards.h" />
|
||||
<ClInclude Include="..\src\kiwano\2d\Action.h" />
|
||||
<ClInclude Include="..\src\kiwano\2d\ActionGroup.h" />
|
||||
<ClInclude Include="..\src\kiwano\2d\ActionHelper.h" />
|
||||
<ClInclude Include="..\src\kiwano\2d\ActionManager.h" />
|
||||
<ClInclude Include="..\src\kiwano\2d\ActionTween.h" />
|
||||
<ClInclude Include="..\src\kiwano\2d\Animation.h" />
|
||||
<ClInclude Include="..\src\kiwano\2d\Canvas.h" />
|
||||
<ClInclude Include="..\src\kiwano\2d\Color.h" />
|
||||
<ClInclude Include="..\src\kiwano\2d\DebugNode.h" />
|
||||
<ClInclude Include="..\src\kiwano\2d\Font.hpp" />
|
||||
<ClInclude Include="..\src\kiwano\2d\Frames.h" />
|
||||
<ClInclude Include="..\src\kiwano\2d\Geometry.h" />
|
||||
<ClInclude Include="..\src\kiwano\2d\GeometryNode.h" />
|
||||
<ClInclude Include="..\src\kiwano\2d\GifImage.h" />
|
||||
<ClInclude Include="..\src\kiwano\2d\Image.h" />
|
||||
<ClInclude Include="..\src\kiwano\2d\Layer.h" />
|
||||
<ClInclude Include="..\src\kiwano\2d\Node.h" />
|
||||
<ClInclude Include="..\src\kiwano\2d\Scene.h" />
|
||||
<ClInclude Include="..\src\kiwano\2d\Sprite.h" />
|
||||
<ClInclude Include="..\src\kiwano\2d\Text.h" />
|
||||
<ClInclude Include="..\src\kiwano\2d\TextStyle.hpp" />
|
||||
<ClInclude Include="..\src\kiwano\2d\Transform.hpp" />
|
||||
<ClInclude Include="..\src\kiwano\2d\Transition.h" />
|
||||
<ClInclude Include="..\src\kiwano\base\AsyncTask.h" />
|
||||
<ClInclude Include="..\src\kiwano\base\Component.h" />
|
||||
<ClInclude Include="..\src\kiwano\base\Event.hpp" />
|
||||
<ClInclude Include="..\src\kiwano\base\EventDispatcher.h" />
|
||||
<ClInclude Include="..\src\kiwano\base\EventListener.h" />
|
||||
<ClInclude Include="..\src\kiwano\base\Input.h" />
|
||||
<ClInclude Include="..\src\kiwano\base\keys.hpp" />
|
||||
<ClInclude Include="..\src\kiwano\base\logs.h" />
|
||||
<ClInclude Include="..\src\kiwano\base\Object.h" />
|
||||
<ClInclude Include="..\src\kiwano\base\RefCounter.hpp" />
|
||||
<ClInclude Include="..\src\kiwano\base\Resource.h" />
|
||||
<ClInclude Include="..\src\kiwano\base\SmartPtr.hpp" />
|
||||
<ClInclude Include="..\src\kiwano\base\Timer.h" />
|
||||
<ClInclude Include="..\src\kiwano\base\TimerManager.h" />
|
||||
<ClInclude Include="..\src\kiwano\base\time.h" />
|
||||
<ClInclude Include="..\src\kiwano\base\window.h" />
|
||||
<ClInclude Include="..\src\kiwano\common\Array.hpp" />
|
||||
<ClInclude Include="..\src\kiwano\common\Closure.hpp" />
|
||||
<ClInclude Include="..\src\kiwano\common\ComPtr.hpp" />
|
||||
<ClInclude Include="..\src\kiwano\common\helper.h" />
|
||||
<ClInclude Include="..\src\kiwano\common\IntrusiveList.hpp" />
|
||||
<ClInclude Include="..\src\kiwano\common\IntrusivePtr.hpp" />
|
||||
<ClInclude Include="..\src\kiwano\common\Json.hpp" />
|
||||
<ClInclude Include="..\src\kiwano\common\Noncopyable.hpp" />
|
||||
<ClInclude Include="..\src\kiwano\common\Singleton.hpp" />
|
||||
<ClInclude Include="..\src\kiwano\common\String.hpp" />
|
||||
<ClInclude Include="..\src\kiwano\math\constants.hpp" />
|
||||
<ClInclude Include="..\src\kiwano\math\ease.hpp" />
|
||||
<ClInclude Include="..\src\kiwano\math\helper.h" />
|
||||
<ClInclude Include="..\src\kiwano\math\Matrix.hpp" />
|
||||
<ClInclude Include="..\src\kiwano\math\rand.h" />
|
||||
<ClInclude Include="..\src\kiwano\math\Rect.hpp" />
|
||||
<ClInclude Include="..\src\kiwano\math\scalar.hpp" />
|
||||
<ClInclude Include="..\src\kiwano\math\Vec2.hpp" />
|
||||
<ClInclude Include="..\src\kiwano\platform\Application.h" />
|
||||
<ClInclude Include="..\src\kiwano\platform\modules.h" />
|
||||
<ClInclude Include="..\src\kiwano\renderer\D2DDeviceResources.h" />
|
||||
<ClInclude Include="..\src\kiwano\renderer\D3D10DeviceResources.h" />
|
||||
<ClInclude Include="..\src\kiwano\renderer\D3D11DeviceResources.h" />
|
||||
<ClInclude Include="..\src\kiwano\renderer\D3DDeviceResourcesBase.h" />
|
||||
<ClInclude Include="..\src\kiwano\renderer\helper.hpp" />
|
||||
<ClInclude Include="..\src\kiwano\renderer\render.h" />
|
||||
<ClInclude Include="..\src\kiwano\renderer\TextRenderer.h" />
|
||||
<ClInclude Include="..\src\kiwano\third-party\StackWalker\StackWalker.h" />
|
||||
<ClInclude Include="..\src\kiwano\third-party\tinyxml2\tinyxml2.h" />
|
||||
<ClInclude Include="..\src\kiwano\ui\Button.h" />
|
||||
<ClInclude Include="..\src\kiwano\ui\Menu.h" />
|
||||
<ClInclude Include="..\src\kiwano\utils\DataUtil.h" />
|
||||
<ClInclude Include="..\src\kiwano\utils\FileUtil.h" />
|
||||
<ClInclude Include="..\src\kiwano\utils\Path.h" />
|
||||
<ClInclude Include="..\src\kiwano\utils\ResLoader.h" />
|
||||
<ClInclude Include="..\src\kiwano\math\helper.h">
|
||||
<Filter>math</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\kiwano\math\Vec2.hpp">
|
||||
<Filter>math</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\kiwano\base\Input.h">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\kiwano\base\window.h">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\kiwano\base\SmartPtr.hpp">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\kiwano\base\Object.h">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\kiwano\kiwano.h" />
|
||||
<ClInclude Include="..\src\kiwano\utils\DataUtil.h">
|
||||
<Filter>utils</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\kiwano\base\Timer.h">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\kiwano\base\TimerManager.h">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\kiwano\base\AsyncTask.h">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\kiwano\2d\GifImage.h">
|
||||
<Filter>2d</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\kiwano\third-party\StackWalker\StackWalker.h">
|
||||
<Filter>third-party\StackWalker</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\kiwano\utils\FileUtil.h">
|
||||
<Filter>utils</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\kiwano\renderer\D3DDeviceResourcesBase.h">
|
||||
<Filter>renderer</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\kiwano\base\types.h">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\kiwano\2d\GifSprite.h">
|
||||
<Filter>2d</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\kiwano\common\Closure.hpp">
|
||||
<Filter>common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\kiwano\common\Noncopyable.hpp">
|
||||
<Filter>common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\kiwano\common\String.hpp">
|
||||
<Filter>common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\kiwano\common\Json.hpp">
|
||||
<Filter>common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\kiwano\common\Array.hpp">
|
||||
<Filter>common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\kiwano\third-party\tinyxml2\tinyxml2.h">
|
||||
<Filter>third-party\tinyxml2</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\kiwano\2d\ShapeNode.h">
|
||||
<Filter>2d</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\src\kiwano\2d\Action.cpp" />
|
||||
<ClCompile Include="..\src\kiwano\2d\ActionGroup.cpp" />
|
||||
<ClCompile Include="..\src\kiwano\2d\ActionManager.cpp" />
|
||||
<ClCompile Include="..\src\kiwano\2d\ActionTween.cpp" />
|
||||
<ClCompile Include="..\src\kiwano\2d\Animation.cpp" />
|
||||
<ClCompile Include="..\src\kiwano\2d\Canvas.cpp" />
|
||||
<ClCompile Include="..\src\kiwano\2d\Color.cpp" />
|
||||
<ClCompile Include="..\src\kiwano\2d\DebugNode.cpp" />
|
||||
<ClCompile Include="..\src\kiwano\2d\Frames.cpp" />
|
||||
<ClCompile Include="..\src\kiwano\2d\Geometry.cpp" />
|
||||
<ClCompile Include="..\src\kiwano\2d\GeometryNode.cpp" />
|
||||
<ClCompile Include="..\src\kiwano\2d\GifImage.cpp" />
|
||||
<ClCompile Include="..\src\kiwano\2d\GifSprite.cpp" />
|
||||
<ClCompile Include="..\src\kiwano\2d\Image.cpp" />
|
||||
<ClCompile Include="..\src\kiwano\2d\Layer.cpp" />
|
||||
<ClCompile Include="..\src\kiwano\2d\Node.cpp" />
|
||||
<ClCompile Include="..\src\kiwano\2d\Scene.cpp" />
|
||||
<ClCompile Include="..\src\kiwano\2d\Sprite.cpp" />
|
||||
<ClCompile Include="..\src\kiwano\2d\Text.cpp" />
|
||||
<ClCompile Include="..\src\kiwano\2d\Transition.cpp" />
|
||||
<ClCompile Include="..\src\kiwano\base\AsyncTask.cpp" />
|
||||
<ClCompile Include="..\src\kiwano\base\EventDispatcher.cpp" />
|
||||
<ClCompile Include="..\src\kiwano\base\EventListener.cpp" />
|
||||
<ClCompile Include="..\src\kiwano\base\Input.cpp" />
|
||||
<ClCompile Include="..\src\kiwano\base\logs.cpp" />
|
||||
<ClCompile Include="..\src\kiwano\base\Object.cpp" />
|
||||
<ClCompile Include="..\src\kiwano\base\Resource.cpp" />
|
||||
<ClCompile Include="..\src\kiwano\base\Timer.cpp" />
|
||||
<ClCompile Include="..\src\kiwano\base\TimerManager.cpp" />
|
||||
<ClCompile Include="..\src\kiwano\base\time.cpp" />
|
||||
<ClCompile Include="..\src\kiwano\base\window.cpp" />
|
||||
<ClCompile Include="..\src\kiwano\platform\Application.cpp" />
|
||||
<ClCompile Include="..\src\kiwano\platform\modules.cpp" />
|
||||
<ClCompile Include="..\src\kiwano\renderer\D2DDeviceResources.cpp" />
|
||||
<ClCompile Include="..\src\kiwano\renderer\D3D10DeviceResources.cpp" />
|
||||
<ClCompile Include="..\src\kiwano\renderer\D3D11DeviceResources.cpp" />
|
||||
<ClCompile Include="..\src\kiwano\renderer\render.cpp" />
|
||||
<ClCompile Include="..\src\kiwano\renderer\TextRenderer.cpp" />
|
||||
<ClCompile Include="..\src\kiwano\third-party\StackWalker\StackWalker.cpp" />
|
||||
<ClCompile Include="..\src\kiwano\third-party\tinyxml2\tinyxml2.cpp" />
|
||||
<ClCompile Include="..\src\kiwano\ui\Button.cpp" />
|
||||
<ClCompile Include="..\src\kiwano\ui\Menu.cpp" />
|
||||
<ClCompile Include="..\src\kiwano\utils\DataUtil.cpp" />
|
||||
<ClCompile Include="..\src\kiwano\utils\FileUtil.cpp" />
|
||||
<ClCompile Include="..\src\kiwano\utils\Path.cpp" />
|
||||
<ClCompile Include="..\src\kiwano\utils\ResLoader.cpp" />
|
||||
<ClCompile Include="..\src\kiwano\ui\Button.cpp">
|
||||
<Filter>ui</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\kiwano\ui\Menu.cpp">
|
||||
<Filter>ui</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\kiwano\2d\Action.cpp">
|
||||
<Filter>2d</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\kiwano\2d\ActionGroup.cpp">
|
||||
<Filter>2d</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\kiwano\2d\ActionManager.cpp">
|
||||
<Filter>2d</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\kiwano\2d\ActionTween.cpp">
|
||||
<Filter>2d</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\kiwano\2d\Animation.cpp">
|
||||
<Filter>2d</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\kiwano\2d\Canvas.cpp">
|
||||
<Filter>2d</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\kiwano\2d\Color.cpp">
|
||||
<Filter>2d</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\kiwano\2d\DebugNode.cpp">
|
||||
<Filter>2d</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\kiwano\2d\Frames.cpp">
|
||||
<Filter>2d</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\kiwano\2d\Image.cpp">
|
||||
<Filter>2d</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\kiwano\2d\Layer.cpp">
|
||||
<Filter>2d</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\kiwano\2d\Node.cpp">
|
||||
<Filter>2d</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\kiwano\2d\Scene.cpp">
|
||||
<Filter>2d</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\kiwano\2d\Sprite.cpp">
|
||||
<Filter>2d</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\kiwano\2d\Text.cpp">
|
||||
<Filter>2d</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\kiwano\2d\Transition.cpp">
|
||||
<Filter>2d</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\kiwano\base\EventDispatcher.cpp">
|
||||
<Filter>base</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\kiwano\base\EventListener.cpp">
|
||||
<Filter>base</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\kiwano\base\logs.cpp">
|
||||
<Filter>base</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\kiwano\base\Resource.cpp">
|
||||
<Filter>base</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\kiwano\base\time.cpp">
|
||||
<Filter>base</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\kiwano\renderer\D2DDeviceResources.cpp">
|
||||
<Filter>renderer</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\kiwano\renderer\D3D10DeviceResources.cpp">
|
||||
<Filter>renderer</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\kiwano\renderer\D3D11DeviceResources.cpp">
|
||||
<Filter>renderer</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\kiwano\renderer\render.cpp">
|
||||
<Filter>renderer</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\kiwano\renderer\TextRenderer.cpp">
|
||||
<Filter>renderer</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\kiwano\platform\Application.cpp">
|
||||
<Filter>platform</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\kiwano\platform\modules.cpp">
|
||||
<Filter>platform</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\kiwano\utils\Path.cpp">
|
||||
<Filter>utils</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\kiwano\utils\ResLoader.cpp">
|
||||
<Filter>utils</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\kiwano\base\Input.cpp">
|
||||
<Filter>base</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\kiwano\base\window.cpp">
|
||||
<Filter>base</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\kiwano\base\Object.cpp">
|
||||
<Filter>base</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\kiwano\utils\DataUtil.cpp">
|
||||
<Filter>utils</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\kiwano\base\Timer.cpp">
|
||||
<Filter>base</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\kiwano\base\TimerManager.cpp">
|
||||
<Filter>base</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\kiwano\base\AsyncTask.cpp">
|
||||
<Filter>base</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\kiwano\2d\GifImage.cpp">
|
||||
<Filter>2d</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\kiwano\third-party\StackWalker\StackWalker.cpp">
|
||||
<Filter>third-party\StackWalker</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\kiwano\utils\FileUtil.cpp">
|
||||
<Filter>utils</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\kiwano\2d\GifSprite.cpp">
|
||||
<Filter>2d</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\kiwano\third-party\tinyxml2\tinyxml2.cpp">
|
||||
<Filter>third-party\tinyxml2</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\kiwano\2d\ShapeNode.cpp">
|
||||
<Filter>2d</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
// Copyright (C) 2019 Nomango
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "common.h"
|
||||
|
||||
// ¹Ì¶¨µÄľ°å
|
||||
KGE_DECLARE_SMART_PTR(Board);
|
||||
class Board
|
||||
: public GeometryNode
|
||||
{
|
||||
public:
|
||||
Board(b2World* world, const Size& size, const Point& pos)
|
||||
{
|
||||
GeometryPtr geo = new RectangleGeometry(Point(), size);
|
||||
SetGeometry(geo);
|
||||
SetStrokeColor(Color::White);
|
||||
SetFillColor(Color(0, 0, 0, 0));
|
||||
|
||||
SetSize(size);
|
||||
SetAnchor(0.5f, 0.5f);
|
||||
SetRotation(10);
|
||||
SetPosition(pos);
|
||||
|
||||
b2BodyDef groundBodyDef;
|
||||
groundBodyDef.position = Vec2Convert(GetPosition());
|
||||
groundBodyDef.angle = 10 * math::constants::PI_F / 180.f;
|
||||
|
||||
b2Body* groundBody = world->CreateBody(&groundBodyDef);
|
||||
|
||||
b2PolygonShape groundBox;
|
||||
b2Vec2 sz = Vec2Convert(Point{ size.x / 2, size.y / 2 });
|
||||
groundBox.SetAsBox(sz.x, sz.y);
|
||||
groundBody->CreateFixture(&groundBox, 0.0f);
|
||||
}
|
||||
};
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<ClCompile Include="main.cpp" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
@ -1,109 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{324CFF47-4EB2-499A-BE5F-53A82E3BA14B}</ProjectGuid>
|
||||
<RootNamespace>Box2DSample</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<PlatformToolset>$(DefaultPlatformToolset)</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<WholeProgramOptimization>false</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<PlatformToolset>$(DefaultPlatformToolset)</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<OutDir>$(SolutionDir)\output\$(PlatformToolset)\$(Platform)\$(Configuration)\</OutDir>
|
||||
<IntDir>$(SolutionDir)\build\$(PlatformToolset)\$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<OutDir>$(SolutionDir)\output\$(PlatformToolset)\$(Platform)\$(Configuration)\</OutDir>
|
||||
<IntDir>$(SolutionDir)\build\$(PlatformToolset)\$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<AdditionalIncludeDirectories>../../src;</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<AdditionalIncludeDirectories>../../src;</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="main.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\projects\kiwano.vcxproj">
|
||||
<Project>{ff7f943d-a89c-4e6c-97cf-84f7d8ff8edf}</Project>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Board.h" />
|
||||
<ClInclude Include="Circle.h" />
|
||||
<ClInclude Include="common.h" />
|
||||
<ClInclude Include="MainScene.h" />
|
||||
<ClInclude Include="Rect.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
<Import Project="..\..\packages\Box2D.2.3.0\build\native\Box2D.targets" Condition="Exists('..\..\packages\Box2D.2.3.0\build\native\Box2D.targets')" />
|
||||
</ImportGroup>
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
<PropertyGroup>
|
||||
<ErrorText>这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\..\packages\Box2D.2.3.0\build\native\Box2D.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Box2D.2.3.0\build\native\Box2D.targets'))" />
|
||||
</Target>
|
||||
</Project>
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
// Copyright (C) 2019 Nomango
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "common.h"
|
||||
|
||||
// Ô²ÐÎ
|
||||
KGE_DECLARE_SMART_PTR(Circle);
|
||||
class Circle
|
||||
: public Sprite
|
||||
{
|
||||
public:
|
||||
Circle(b2World* world, const Point& pos)
|
||||
{
|
||||
Load(L"circle.png");
|
||||
SetAnchor(0.5f, 0.5f);
|
||||
SetScale(0.7f);
|
||||
|
||||
b2BodyDef bodyDef;
|
||||
bodyDef.type = b2_dynamicBody;
|
||||
bodyDef.position = Vec2Convert(pos);
|
||||
|
||||
b2Body* body = world->CreateBody(&bodyDef);
|
||||
|
||||
SetUserData(body);
|
||||
|
||||
b2CircleShape shape;
|
||||
shape.m_radius = GetWidth() / GLOBAL_SCALE / 2 * 0.7f;
|
||||
|
||||
b2FixtureDef fixtureDef;
|
||||
fixtureDef.shape = &shape;
|
||||
fixtureDef.density = 1.0f;
|
||||
fixtureDef.friction = 0.3f;
|
||||
|
||||
body->CreateFixture(&fixtureDef);
|
||||
body->SetUserData(this);
|
||||
}
|
||||
};
|
||||
|
|
@ -1,84 +0,0 @@
|
|||
// Copyright (C) 2019 Nomango
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Circle.h"
|
||||
#include "Rect.h"
|
||||
#include "Board.h"
|
||||
|
||||
KGE_DECLARE_SMART_PTR(MainScene);
|
||||
class MainScene
|
||||
: public Scene
|
||||
{
|
||||
b2World* world_;
|
||||
|
||||
public:
|
||||
MainScene()
|
||||
{
|
||||
// 设置可响应状态, 使场景可以接收到鼠标 Click 消息
|
||||
SetResponsible(true);
|
||||
|
||||
// 添加消息监听
|
||||
AddListener(Event::Click, MakeClosure(this, &MainScene::Click));
|
||||
|
||||
// 创建物理世界
|
||||
world_ = new b2World(b2Vec2(0, 10));
|
||||
|
||||
BoardPtr board = new Board(world_, Size(GetWidth() - 100, 20), Point(GetWidth() / 2, GetHeight() - 50));
|
||||
AddChild(board);
|
||||
|
||||
CirclePtr circle = new Circle(world_, Point(320, 240));
|
||||
AddChild(circle);
|
||||
}
|
||||
|
||||
~MainScene()
|
||||
{
|
||||
if (world_)
|
||||
delete world_;
|
||||
}
|
||||
|
||||
void OnUpdate(Duration dt) override
|
||||
{
|
||||
// 更新 Box2D 世界
|
||||
world_->Step(dt.Seconds(), 6, 2);
|
||||
|
||||
// 更新每一个物理对象的位置和旋转角度
|
||||
b2Body* body = world_->GetBodyList();
|
||||
while (body)
|
||||
{
|
||||
Node* node = (Node*)body->GetUserData();
|
||||
b2Body* next = body->GetNext();
|
||||
if (node)
|
||||
{
|
||||
const b2Vec2& pos = body->GetPosition();
|
||||
node->SetPosition(Vec2Convert(pos));
|
||||
node->SetRotation(body->GetAngle() * 180.f / math::constants::PI_F);
|
||||
|
||||
// 移除掉落到场景外的物体
|
||||
if (node->GetPosition().y > GetHeight() + 50)
|
||||
{
|
||||
body->SetUserData(0);
|
||||
world_->DestroyBody(body);
|
||||
|
||||
node->RemoveFromParent();
|
||||
}
|
||||
}
|
||||
|
||||
body = next;
|
||||
}
|
||||
}
|
||||
|
||||
void Click(Event const& evt)
|
||||
{
|
||||
if (evt.mouse.button == MouseButton::Left)
|
||||
{
|
||||
CirclePtr circle = new Circle(world_, Point{ evt.mouse.x, evt.mouse.y });
|
||||
AddChild(circle);
|
||||
}
|
||||
else if (evt.mouse.button == MouseButton::Right)
|
||||
{
|
||||
SquarePtr rect = new Square(world_, Point{ evt.mouse.x, evt.mouse.y });
|
||||
AddChild(rect);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -1,39 +0,0 @@
|
|||
// Copyright (C) 2019 Nomango
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "common.h"
|
||||
|
||||
// ·½¿é
|
||||
KGE_DECLARE_SMART_PTR(Square);
|
||||
class Square
|
||||
: public Sprite
|
||||
{
|
||||
public:
|
||||
Square(b2World* world, const Point& pos)
|
||||
{
|
||||
Load(L"square.png");
|
||||
SetAnchor(0.5f, 0.5f);
|
||||
SetScale(0.7f);
|
||||
|
||||
b2BodyDef bodyDef;
|
||||
bodyDef.type = b2_dynamicBody;
|
||||
bodyDef.position = Vec2Convert(pos);
|
||||
|
||||
b2Body* body = world->CreateBody(&bodyDef);
|
||||
|
||||
SetUserData(body);
|
||||
|
||||
b2PolygonShape shape;
|
||||
b2Vec2 sz = Vec2Convert(GetSize() / 2 * 0.7f);
|
||||
shape.SetAsBox(sz.x, sz.y);
|
||||
|
||||
b2FixtureDef fixtureDef;
|
||||
fixtureDef.shape = &shape;
|
||||
fixtureDef.density = 1.0f;
|
||||
fixtureDef.friction = 0.3f;
|
||||
|
||||
body->CreateFixture(&fixtureDef);
|
||||
body->SetUserData(this);
|
||||
}
|
||||
};
|
||||
|
Before Width: | Height: | Size: 27 KiB |
|
|
@ -1,29 +0,0 @@
|
|||
// Copyright (C) 2019 Nomango
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "kiwano/kiwano.h"
|
||||
#include <Box2D/Box2D.h>
|
||||
|
||||
using namespace kiwano;
|
||||
|
||||
//
|
||||
// Box2D 非常好地适应了 米/千克/秒 的单位, 所以
|
||||
// 它并不是以像素为单位进行计算.
|
||||
// 我们在平衡 Box2D 和 Kiwano 世界的度量时, 需要
|
||||
// 进行一些转换.
|
||||
//
|
||||
namespace
|
||||
{
|
||||
const float GLOBAL_SCALE = 100.0f;
|
||||
|
||||
b2Vec2 Vec2Convert(const Point& pos)
|
||||
{
|
||||
return b2Vec2(pos.x / GLOBAL_SCALE, pos.y / GLOBAL_SCALE);
|
||||
}
|
||||
|
||||
Point Vec2Convert(const b2Vec2& pos)
|
||||
{
|
||||
return Point(pos.x * GLOBAL_SCALE, pos.y * GLOBAL_SCALE);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
// Copyright (C) 2019 Nomango
|
||||
|
||||
#include "MainScene.h"
|
||||
|
||||
int WINAPI wWinMain(_In_ HINSTANCE, _In_opt_ HINSTANCE, _In_ PWSTR, _In_ int)
|
||||
{
|
||||
try
|
||||
{
|
||||
Application app;
|
||||
|
||||
Options options(L"Box2D Demo");
|
||||
app.Init(options);
|
||||
|
||||
MainScenePtr scene = new MainScene;
|
||||
app.EnterScene(scene);
|
||||
app.Run();
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
::MessageBoxA(nullptr, e.what(), "An exception has occurred!", MB_ICONERROR | MB_OK);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Box2D" version="2.3.0" targetFramework="native" />
|
||||
</packages>
|
||||
|
Before Width: | Height: | Size: 19 KiB |
|
|
@ -1,94 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{3561A359-F9FD-48AB-A977-34E7E568BC8E}</ProjectGuid>
|
||||
<RootNamespace>HelloWorld</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<PlatformToolset>$(DefaultPlatformToolset)</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<WholeProgramOptimization>false</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<PlatformToolset>$(DefaultPlatformToolset)</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<OutDir>$(SolutionDir)\output\$(PlatformToolset)\$(Platform)\$(Configuration)\</OutDir>
|
||||
<IntDir>$(SolutionDir)\build\$(PlatformToolset)\$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<OutDir>$(SolutionDir)\output\$(PlatformToolset)\$(Platform)\$(Configuration)\</OutDir>
|
||||
<IntDir>$(SolutionDir)\build\$(PlatformToolset)\$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<AdditionalIncludeDirectories>../../src;</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<AdditionalIncludeDirectories>../../src;</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="main.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\projects\kiwano.vcxproj">
|
||||
<Project>{ff7f943d-a89c-4e6c-97cf-84f7d8ff8edf}</Project>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<ClCompile Include="main.cpp" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
@ -1,41 +0,0 @@
|
|||
// Copyright (C) 2019 Nomango
|
||||
|
||||
#include "kiwano/kiwano.h"
|
||||
|
||||
using namespace kiwano;
|
||||
|
||||
class MainScene
|
||||
: public Scene
|
||||
{
|
||||
public:
|
||||
MainScene()
|
||||
{
|
||||
TextPtr text = new Text(L"Hello Kiwano!"); // 创建文字节点
|
||||
text->SetSize(text->GetLayoutSize()); // 设置节点大小为文字布局大小
|
||||
text->SetPosition(640 / 2, 480 / 2); // 修改节点位置, 使节点在屏幕上居中
|
||||
text->SetAnchor(0.5, 0.5); // 修改节点锚点, 使文字中心对齐屏幕中心
|
||||
this->AddChild(text); // 添加到场景中
|
||||
}
|
||||
};
|
||||
|
||||
int WINAPI wWinMain(_In_ HINSTANCE, _In_opt_ HINSTANCE, _In_ PWSTR, _In_ int)
|
||||
{
|
||||
// 创建 Kiwano 程序实例
|
||||
Application app;
|
||||
|
||||
// 在初始化选项中设置窗口宽高
|
||||
Options options;
|
||||
options.width = 640;
|
||||
options.height = 480;
|
||||
|
||||
// 初始化 app
|
||||
app.Init(options);
|
||||
|
||||
// 创建场景并进入
|
||||
ScenePtr scene = new MainScene;
|
||||
app.EnterScene(scene);
|
||||
|
||||
// 运行
|
||||
app.Run();
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
# ImGui Configuration
|
||||
imgui.ini
|
||||
|
|
@ -1,98 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{6152D36C-EA40-4968-A696-244B6CA58395}</ProjectGuid>
|
||||
<RootNamespace>ImGuiSample</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<PlatformToolset>$(DefaultPlatformToolset)</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<WholeProgramOptimization>false</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<PlatformToolset>$(DefaultPlatformToolset)</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<OutDir>$(SolutionDir)\output\$(PlatformToolset)\$(Platform)\$(Configuration)\</OutDir>
|
||||
<IntDir>$(SolutionDir)\build\$(PlatformToolset)\$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<OutDir>$(SolutionDir)\output\$(PlatformToolset)\$(Platform)\$(Configuration)\</OutDir>
|
||||
<IntDir>$(SolutionDir)\build\$(PlatformToolset)\$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<AdditionalIncludeDirectories>../../src;</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<AdditionalIncludeDirectories>../../src;</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="main.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\projects\kiwano-imgui.vcxproj">
|
||||
<Project>{a7062ed8-8910-48a5-a3bc-c1612672571f}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\projects\kiwano.vcxproj">
|
||||
<Project>{ff7f943d-a89c-4e6c-97cf-84f7d8ff8edf}</Project>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="MainScene.h" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<ClCompile Include="main.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="MainScene.h" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
@ -1,76 +0,0 @@
|
|||
// Copyright (C) 2019 Nomango
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "kiwano/kiwano.h"
|
||||
#include "kiwano-imgui/kiwano-imgui.h"
|
||||
|
||||
using namespace kiwano;
|
||||
using namespace kiwano::imgui;
|
||||
|
||||
KGE_DECLARE_SMART_PTR(MainScene);
|
||||
class MainScene
|
||||
: public Scene
|
||||
{
|
||||
bool show_demo_window = true;
|
||||
bool show_another_window = false;
|
||||
Color clear_color = Color(0.45f, 0.55f, 0.6f, 1.f);
|
||||
|
||||
public:
|
||||
MainScene()
|
||||
{
|
||||
// 创建 ImGui 图层
|
||||
ImGuiLayerPtr layer = new ImGuiLayer;
|
||||
AddChild(layer);
|
||||
|
||||
// 添加 ImGui 提供的 Demo 窗口
|
||||
layer->AddItem([=]() {
|
||||
if (show_demo_window)
|
||||
ImGui::ShowDemoWindow(&show_demo_window);
|
||||
}, L"DemoWindow");
|
||||
|
||||
// 添加一个简单窗口
|
||||
layer->AddItem(MakeClosure(this, &MainScene::SimpleWindow), L"SimpleWindow");
|
||||
|
||||
// 再添加一个窗口
|
||||
layer->AddItem(MakeClosure(this, &MainScene::AnotherWindow), L"AnotherWindow");
|
||||
}
|
||||
|
||||
void SimpleWindow()
|
||||
{
|
||||
static float f = 0.0f;
|
||||
static int counter = 0;
|
||||
|
||||
ImGui::Begin("Hello, world!");
|
||||
|
||||
ImGui::Text("This is some useful text.");
|
||||
ImGui::Checkbox("Demo Window", &show_demo_window);
|
||||
ImGui::Checkbox("Another Window", &show_another_window);
|
||||
|
||||
ImGui::SliderFloat("float", &f, 0.0f, 1.0f);
|
||||
ImGui::ColorEdit3("clear color", (float*)&clear_color);
|
||||
|
||||
if (ImGui::Button("Button"))
|
||||
counter++;
|
||||
ImGui::SameLine();
|
||||
ImGui::Text("counter = %d", counter);
|
||||
|
||||
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
|
||||
ImGui::End();
|
||||
|
||||
// 修改窗口背景色
|
||||
Renderer::Instance()->SetClearColor(clear_color);
|
||||
}
|
||||
|
||||
void AnotherWindow()
|
||||
{
|
||||
if (show_another_window)
|
||||
{
|
||||
ImGui::Begin("Another Window", &show_another_window);
|
||||
ImGui::Text("Hello from another window!");
|
||||
if (ImGui::Button("Close Me"))
|
||||
show_another_window = false;
|
||||
ImGui::End();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -1,40 +0,0 @@
|
|||
// Copyright (C) 2019 Nomango
|
||||
|
||||
#include "MainScene.h"
|
||||
|
||||
using namespace kiwano;
|
||||
|
||||
class ImGuiApp
|
||||
: public Application
|
||||
{
|
||||
public:
|
||||
ImGuiApp()
|
||||
{
|
||||
// Ìí¼Ó ImGui ×é¼þ
|
||||
Use(ImGuiModule::Instance());
|
||||
|
||||
// ³õʼ»¯
|
||||
Options options(L"ImGui Demo", 1280, 800);
|
||||
Init(options);
|
||||
}
|
||||
|
||||
void OnStart() override
|
||||
{
|
||||
MainScenePtr scene = new MainScene;
|
||||
EnterScene(scene);
|
||||
}
|
||||
};
|
||||
|
||||
int WINAPI wWinMain(_In_ HINSTANCE, _In_opt_ HINSTANCE, _In_ PWSTR, _In_ int)
|
||||
{
|
||||
try
|
||||
{
|
||||
ImGuiApp app;
|
||||
app.Run();
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
::MessageBoxA(nullptr, e.what(), "An exception has occurred!", MB_ICONERROR | MB_OK);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1,75 +0,0 @@
|
|||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.28729.10
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HelloWorld", "HelloWorld\HelloWorld.vcxproj", "{3561A359-F9FD-48AB-A977-34E7E568BC8E}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Samples", "Samples\Samples.vcxproj", "{45F5738D-CDF2-4024-974D-25B64F9043DE}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ImGuiSample", "ImGuiSample\ImGuiSample.vcxproj", "{6152D36C-EA40-4968-A696-244B6CA58395}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Box2DSample", "Box2DSample\Box2DSample.vcxproj", "{324CFF47-4EB2-499A-BE5F-53A82E3BA14B}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "kiwano", "..\projects\kiwano.vcxproj", "{FF7F943D-A89C-4E6C-97CF-84F7D8FF8EDF}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "kiwano-audio", "..\projects\kiwano-audio.vcxproj", "{1B97937D-8184-426C-BE71-29A163DC76C9}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "kiwano-network", "..\projects\kiwano-network.vcxproj", "{69DFBE92-C06F-4CF8-9495-CA9BF2E3BAF2}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "kiwano-imgui", "..\projects\kiwano-imgui.vcxproj", "{A7062ED8-8910-48A5-A3BC-C1612672571F}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Libraries", "Libraries", "{44D7EDE1-8C27-4608-8018-F891280A77B2}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Win32 = Debug|Win32
|
||||
Release|Win32 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{3561A359-F9FD-48AB-A977-34E7E568BC8E}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{3561A359-F9FD-48AB-A977-34E7E568BC8E}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{3561A359-F9FD-48AB-A977-34E7E568BC8E}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{3561A359-F9FD-48AB-A977-34E7E568BC8E}.Release|Win32.Build.0 = Release|Win32
|
||||
{FF7F943D-A89C-4E6C-97CF-84F7D8FF8EDF}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{FF7F943D-A89C-4E6C-97CF-84F7D8FF8EDF}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{FF7F943D-A89C-4E6C-97CF-84F7D8FF8EDF}.Debug|Win32.Deploy.0 = Debug|Win32
|
||||
{FF7F943D-A89C-4E6C-97CF-84F7D8FF8EDF}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{FF7F943D-A89C-4E6C-97CF-84F7D8FF8EDF}.Release|Win32.Build.0 = Release|Win32
|
||||
{45F5738D-CDF2-4024-974D-25B64F9043DE}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{45F5738D-CDF2-4024-974D-25B64F9043DE}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{45F5738D-CDF2-4024-974D-25B64F9043DE}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{45F5738D-CDF2-4024-974D-25B64F9043DE}.Release|Win32.Build.0 = Release|Win32
|
||||
{6152D36C-EA40-4968-A696-244B6CA58395}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{6152D36C-EA40-4968-A696-244B6CA58395}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{6152D36C-EA40-4968-A696-244B6CA58395}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{6152D36C-EA40-4968-A696-244B6CA58395}.Release|Win32.Build.0 = Release|Win32
|
||||
{324CFF47-4EB2-499A-BE5F-53A82E3BA14B}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{324CFF47-4EB2-499A-BE5F-53A82E3BA14B}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{324CFF47-4EB2-499A-BE5F-53A82E3BA14B}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{324CFF47-4EB2-499A-BE5F-53A82E3BA14B}.Release|Win32.Build.0 = Release|Win32
|
||||
{1B97937D-8184-426C-BE71-29A163DC76C9}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{1B97937D-8184-426C-BE71-29A163DC76C9}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{1B97937D-8184-426C-BE71-29A163DC76C9}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{1B97937D-8184-426C-BE71-29A163DC76C9}.Release|Win32.Build.0 = Release|Win32
|
||||
{69DFBE92-C06F-4CF8-9495-CA9BF2E3BAF2}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{69DFBE92-C06F-4CF8-9495-CA9BF2E3BAF2}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{69DFBE92-C06F-4CF8-9495-CA9BF2E3BAF2}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{69DFBE92-C06F-4CF8-9495-CA9BF2E3BAF2}.Release|Win32.Build.0 = Release|Win32
|
||||
{A7062ED8-8910-48A5-A3BC-C1612672571F}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{A7062ED8-8910-48A5-A3BC-C1612672571F}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{A7062ED8-8910-48A5-A3BC-C1612672571F}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{A7062ED8-8910-48A5-A3BC-C1612672571F}.Release|Win32.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(NestedProjects) = preSolution
|
||||
{FF7F943D-A89C-4E6C-97CF-84F7D8FF8EDF} = {44D7EDE1-8C27-4608-8018-F891280A77B2}
|
||||
{1B97937D-8184-426C-BE71-29A163DC76C9} = {44D7EDE1-8C27-4608-8018-F891280A77B2}
|
||||
{69DFBE92-C06F-4CF8-9495-CA9BF2E3BAF2} = {44D7EDE1-8C27-4608-8018-F891280A77B2}
|
||||
{A7062ED8-8910-48A5-A3BC-C1612672571F} = {44D7EDE1-8C27-4608-8018-F891280A77B2}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {FAC2BE2F-19AF-477A-8DC6-4645E66868A4}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
|
@ -1,55 +0,0 @@
|
|||
// Copyright (C) 2019 Nomango
|
||||
|
||||
#pragma once
|
||||
#include "common.h"
|
||||
|
||||
class Demo1
|
||||
: public Scene
|
||||
{
|
||||
public:
|
||||
static ScenePtr Create()
|
||||
{
|
||||
return new Demo1;
|
||||
}
|
||||
|
||||
Demo1()
|
||||
{
|
||||
// 获取人物图片
|
||||
ImagePtr man_image = g_Loader.GetImage(L"man");
|
||||
|
||||
// 缓动方程
|
||||
auto ease_functions = {
|
||||
Ease::Linear, // 线性变化
|
||||
Ease::EaseInOut, // 变化过程中有缓冲
|
||||
Ease::ExpoInOut, // 在开始和结束阶段非常慢,但过程非常快
|
||||
Ease::BounceInOut, // 在开始和结束阶段均赋予弹性
|
||||
Ease::BackInOut // 开始和结束阶段均有一个短暂的反方向运动
|
||||
};
|
||||
|
||||
float height = 100.f;
|
||||
for (auto& func : ease_functions)
|
||||
{
|
||||
SpritePtr man = new Sprite(man_image);
|
||||
man->SetPosition(100, height);
|
||||
man->SetScale(0.5f, 0.3f);
|
||||
this->AddChild(man);
|
||||
|
||||
// 重置人物位置函数
|
||||
auto reset_pos = [ptr = man.Get()]() { ptr->Move(-350, 0); };
|
||||
|
||||
// 执行动画
|
||||
man->AddAction(
|
||||
Tween::Group({ // Tween::Group 组合动画
|
||||
Tween::MoveBy(Point{ 350, 0 }) // Tween::MoveBy 横向位移 350 像素
|
||||
.SetDuration(4000) // 设置位移时间为 4 秒
|
||||
.SetEaseFunc(func), // 设置缓动函数
|
||||
Tween::Delay(1000) // Tween::Delay 延迟 1 秒
|
||||
})
|
||||
.SetLoops(-1) // 无限循环执行
|
||||
.SetLoopDoneCallback(reset_pos) // 设置每次循环结束都重置人物位置
|
||||
);
|
||||
|
||||
height += 60.f;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -1,96 +0,0 @@
|
|||
// Copyright (C) 2019 Nomango
|
||||
|
||||
#pragma once
|
||||
#include "common.h"
|
||||
|
||||
// 角色
|
||||
KGE_DECLARE_SMART_PTR(Hero);
|
||||
class Hero
|
||||
: public GifSprite
|
||||
{
|
||||
public:
|
||||
Hero(GifImagePtr image)
|
||||
{
|
||||
// 加载图片
|
||||
Load(image);
|
||||
// 设置 GIF 动图无限循环
|
||||
SetLoopCount(-1);
|
||||
}
|
||||
|
||||
// 每帧渲染前执行 OnUpdate
|
||||
void OnUpdate(Duration dt) override
|
||||
{
|
||||
// 获取输入设备
|
||||
auto input = Input::Instance();
|
||||
|
||||
// 按下左右键
|
||||
if (input->IsDown(KeyCode::Left))
|
||||
{
|
||||
this->Move(-2, 0);
|
||||
}
|
||||
else if (input->IsDown(KeyCode::Right))
|
||||
{
|
||||
this->Move(2, 0);
|
||||
}
|
||||
|
||||
// 按下上下键
|
||||
if (input->IsDown(KeyCode::Up))
|
||||
{
|
||||
this->Move(0, -2);
|
||||
}
|
||||
else if (input->IsDown(KeyCode::Down))
|
||||
{
|
||||
this->Move(0, 2);
|
||||
}
|
||||
|
||||
// 按下鼠标左键,顺时针旋转角色
|
||||
if (input->IsDown(MouseButton::Left))
|
||||
{
|
||||
// 获取当前旋转角度
|
||||
float rotation = this->GetRotation();
|
||||
// 设置角度值+2
|
||||
this->SetRotation(rotation + 2);
|
||||
}
|
||||
|
||||
// 点击鼠标右键,隐藏或显示角色
|
||||
if (input->WasPressed(MouseButton::Right))
|
||||
{
|
||||
// 获取当前显示状态
|
||||
bool visible = this->IsVisible();
|
||||
// 设置相反的显示状态
|
||||
this->SetVisible(!visible);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
class Demo2
|
||||
: public Scene
|
||||
{
|
||||
public:
|
||||
static ScenePtr Create()
|
||||
{
|
||||
return new Demo2;
|
||||
}
|
||||
|
||||
Demo2()
|
||||
{
|
||||
// 创建角色
|
||||
HeroPtr hero = new Hero(g_Loader.GetGifImage(L"Kusanagi"));
|
||||
// 在屏幕上居中显示
|
||||
hero->SetAnchor(0.5f, 0.5f);
|
||||
hero->SetPosition(WINDOW_WIDTH / 2, WINDOW_HEIGHT / 2);
|
||||
|
||||
// 创建说明文字
|
||||
TextPtr text = new Text(L"按上下左右键移动\n按鼠标左键旋转\n点击鼠标右键隐藏");
|
||||
// 设置节点大小为文字布局大小
|
||||
text->SetSize(text->GetLayoutSize());
|
||||
// 设置文字位置
|
||||
text->SetAnchor(0.5f, 0.5f);
|
||||
text->SetPosition(WINDOW_WIDTH / 2, WINDOW_HEIGHT - 50);
|
||||
text->SetAlignment(TextAlign::Center);
|
||||
|
||||
// 添加到场景
|
||||
this->AddChild(hero);
|
||||
this->AddChild(text);
|
||||
}
|
||||
};
|
||||
|
|
@ -1,84 +0,0 @@
|
|||
// Copyright (C) 2019 Nomango
|
||||
|
||||
#pragma once
|
||||
#include "common.h"
|
||||
|
||||
class Demo3
|
||||
: public Scene
|
||||
{
|
||||
SoundPtr bgmusic; // 音乐对象
|
||||
TextPtr volume_text; // 音量文字
|
||||
TextPtr state_text; // 播放状态文字
|
||||
|
||||
public:
|
||||
static ScenePtr Create()
|
||||
{
|
||||
return new Demo3;
|
||||
}
|
||||
|
||||
Demo3()
|
||||
{
|
||||
// 加载音乐
|
||||
bgmusic = new Sound;
|
||||
if (!bgmusic->Load(L"res/splash.mp3"))
|
||||
{
|
||||
bgmusic = nullptr;
|
||||
|
||||
TextPtr err = new Text(L"音频文件加载失败");
|
||||
this->AddChild(err);
|
||||
}
|
||||
|
||||
// 播放音乐(参数用来设置播放循环次数,-1 表示循环播放)
|
||||
bgmusic->Play(-1);
|
||||
|
||||
// 创建说明文字
|
||||
TextPtr intro_text = new Text(L"按上下键调整音量\n按空格键暂停或继续");
|
||||
intro_text->SetPosition(WINDOW_WIDTH / 2 - 80, WINDOW_HEIGHT / 2 - 50);
|
||||
|
||||
// 创建音量文字
|
||||
volume_text = new Text(L"当前音量:");
|
||||
volume_text->SetPosition(WINDOW_WIDTH / 2 - 80, WINDOW_HEIGHT / 2 + 30);
|
||||
|
||||
// 创建状态文字
|
||||
state_text = new Text(L"当前状态:");
|
||||
state_text->SetPosition(WINDOW_WIDTH / 2 - 80, WINDOW_HEIGHT / 2 + 60);
|
||||
|
||||
// 添加到场景
|
||||
this->AddChild(intro_text);
|
||||
this->AddChild(volume_text);
|
||||
this->AddChild(state_text);
|
||||
}
|
||||
|
||||
void OnUpdate(Duration dt) override
|
||||
{
|
||||
if (bgmusic == nullptr)
|
||||
return;
|
||||
|
||||
// 获取音量和播放状态
|
||||
float volume = bgmusic->GetVolume();
|
||||
bool playing = bgmusic->IsPlaying();
|
||||
|
||||
// 修改文本
|
||||
volume_text->SetText(L"当前音量:" + std::to_wstring(volume));
|
||||
state_text->SetText(playing ? L"当前状态:正在播放" : L"当前状态:停止播放");
|
||||
|
||||
// 获取输入设备
|
||||
auto input = Input::Instance();
|
||||
|
||||
// 按空格键暂停或继续
|
||||
if (input->WasPressed(KeyCode::Space))
|
||||
{
|
||||
bgmusic->IsPlaying() ? bgmusic->Pause() : bgmusic->Resume();
|
||||
}
|
||||
|
||||
// 按上下键调整音量
|
||||
if (input->WasPressed(KeyCode::Up))
|
||||
{
|
||||
bgmusic->SetVolume(volume + 0.1f);
|
||||
}
|
||||
else if (input->WasPressed(KeyCode::Down))
|
||||
{
|
||||
bgmusic->SetVolume(volume - 0.1f);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -1,178 +0,0 @@
|
|||
// Copyright (C) 2019 Nomango
|
||||
|
||||
#pragma once
|
||||
#include "common.h"
|
||||
|
||||
// 老虎
|
||||
KGE_DECLARE_SMART_PTR(Tiger);
|
||||
class Tiger
|
||||
: public Sprite
|
||||
{
|
||||
FramesPtr run_frames; // 跑步序列帧
|
||||
FramesPtr stand_frames; // 站立序列帧
|
||||
bool facing_left; // 面朝左或面朝右
|
||||
bool running; // 是否正在跑步
|
||||
Direction running_direction; // 跑步方向
|
||||
|
||||
public:
|
||||
Tiger()
|
||||
{
|
||||
// 加载帧动画
|
||||
run_frames = g_Loader.GetFrames(L"tiger_running");
|
||||
stand_frames = g_Loader.GetFrames(L"tiger_standing");
|
||||
|
||||
// 执行动画
|
||||
AddAction(
|
||||
Tween::Animation(stand_frames)
|
||||
.SetDuration(1000)
|
||||
.SetLoops(-1)
|
||||
);
|
||||
|
||||
// 添加按键监听
|
||||
AddListener(Event::KeyDown, MakeClosure(this, &Tiger::OnKeyDown));
|
||||
AddListener(Event::KeyUp, MakeClosure(this, &Tiger::OnKeyUp));
|
||||
|
||||
// 默认方向为 Left
|
||||
facing_left = true;
|
||||
running = false;
|
||||
|
||||
// 设置锚点
|
||||
SetAnchor(0.5f, 0.5f);
|
||||
}
|
||||
|
||||
void OnKeyDown(Event const& e)
|
||||
{
|
||||
if (e.key.code == KeyCode::Left)
|
||||
Run(Direction::Left);
|
||||
else if (e.key.code == KeyCode::Right)
|
||||
Run(Direction::Right);
|
||||
else if (e.key.code == KeyCode::Up)
|
||||
Run(Direction::Up);
|
||||
else if (e.key.code == KeyCode::Down)
|
||||
Run(Direction::Down);
|
||||
}
|
||||
|
||||
void OnKeyUp(Event const& e)
|
||||
{
|
||||
switch (e.key.code)
|
||||
{
|
||||
case KeyCode::Left:
|
||||
case KeyCode::Right:
|
||||
case KeyCode::Up:
|
||||
case KeyCode::Down:
|
||||
StopRun();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void Run(Direction d)
|
||||
{
|
||||
if (!running)
|
||||
{
|
||||
running = true;
|
||||
StopAllActions();
|
||||
|
||||
// 执行跑步动画
|
||||
AddAction(
|
||||
Tween::Animation(run_frames)
|
||||
.SetDuration(500)
|
||||
.SetLoops(-1)
|
||||
);
|
||||
}
|
||||
|
||||
running_direction = d;
|
||||
if (running_direction == Direction::Left)
|
||||
{
|
||||
facing_left = true;
|
||||
}
|
||||
else if (running_direction == Direction::Right)
|
||||
{
|
||||
facing_left = false;
|
||||
}
|
||||
|
||||
// 缩放可以调整图片显示方向
|
||||
// 缩放至 -1 图片会反转
|
||||
SetScaleX(facing_left ? 1.0f : -1.0f);
|
||||
}
|
||||
|
||||
void StopRun()
|
||||
{
|
||||
if (running)
|
||||
{
|
||||
running = false;
|
||||
StopAllActions();
|
||||
|
||||
// 执行站立动画
|
||||
AddAction(
|
||||
Tween::Animation(stand_frames)
|
||||
.SetDuration(1000)
|
||||
.SetLoops(-1)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void OnUpdate(Duration dt)
|
||||
{
|
||||
if (running)
|
||||
{
|
||||
// 计算移动距离
|
||||
// OnUpdate 并不是一个稳定间隔执行的函数, 如果想实现稳定
|
||||
// 每秒移动 150 像素, 应根据 dt 参数计算移动距离
|
||||
const float moving_per_sec = 150;
|
||||
const float distance = moving_per_sec * dt.Seconds();
|
||||
|
||||
switch (running_direction)
|
||||
{
|
||||
case Direction::Up:
|
||||
Move(0, -distance);
|
||||
break;
|
||||
case Direction::Down:
|
||||
Move(0, distance);
|
||||
break;
|
||||
case Direction::Left:
|
||||
Move(-distance, 0);
|
||||
break;
|
||||
case Direction::Right:
|
||||
Move(distance, 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
class Demo4
|
||||
: public Scene
|
||||
{
|
||||
public:
|
||||
static ScenePtr Create()
|
||||
{
|
||||
return new Demo4;
|
||||
}
|
||||
|
||||
Demo4()
|
||||
{
|
||||
// 创建背景
|
||||
SpritePtr bg = new Sprite(L"res/spring_forest.jpg");
|
||||
bg->SetSize(GetSize());
|
||||
|
||||
// 创建老虎
|
||||
TigerPtr tiger = new Tiger;
|
||||
// 在屏幕上居中显示
|
||||
tiger->SetAnchor(0.5f, 0.5f);
|
||||
tiger->SetPosition(WINDOW_WIDTH / 2, WINDOW_HEIGHT / 2);
|
||||
|
||||
// 创建说明文字
|
||||
TextPtr text = new Text(L"按上下左右键移动");
|
||||
// 设置节点大小为文字布局大小
|
||||
text->SetSize(text->GetLayoutSize());
|
||||
// 设置文字位置
|
||||
text->SetAnchor(0.5f, 0.5f);
|
||||
text->SetPosition(WINDOW_WIDTH / 2, WINDOW_HEIGHT - 80);
|
||||
text->SetAlignment(TextAlign::Center);
|
||||
|
||||
// 添加到场景
|
||||
this->AddChild(bg);
|
||||
this->AddChild(tiger);
|
||||
this->AddChild(text);
|
||||
}
|
||||
};
|
||||
|
|
@ -1,176 +0,0 @@
|
|||
// Copyright (C) 2019 Nomango
|
||||
|
||||
#pragma once
|
||||
#include "common.h"
|
||||
#include <iostream>
|
||||
|
||||
class Demo5
|
||||
: public Scene
|
||||
{
|
||||
public:
|
||||
static ScenePtr Create()
|
||||
{
|
||||
return new Demo5;
|
||||
}
|
||||
|
||||
Demo5()
|
||||
{
|
||||
// 添加按键监听
|
||||
AddListener(Event::KeyDown, MakeClosure(this, &Demo5::OnKeyDown));
|
||||
|
||||
// 创建说明文字
|
||||
TextPtr text = new Text(L"按G发送GET请求\n按P发送POST请求\n按U发送PUT请求\n按D发送DELETE请求");
|
||||
// 设置节点大小为文字布局大小
|
||||
text->SetSize(text->GetLayoutSize());
|
||||
// 设置文字位置
|
||||
text->SetAnchor(0.5f, 0.5f);
|
||||
text->SetPosition(WINDOW_WIDTH / 2, WINDOW_HEIGHT / 2);
|
||||
|
||||
// 添加到场景
|
||||
this->AddChild(text);
|
||||
}
|
||||
|
||||
void OnEnter() override
|
||||
{
|
||||
// 进入场景时打开控制台
|
||||
Logger::Instance()->ShowConsole(true);
|
||||
}
|
||||
|
||||
void OnExit() override
|
||||
{
|
||||
// 退出场景时关闭控制台
|
||||
Logger::Instance()->ShowConsole(false);
|
||||
}
|
||||
|
||||
void OnKeyDown(Event const& e)
|
||||
{
|
||||
// 按不同键发送不同请求
|
||||
if (e.key.code == KeyCode::G)
|
||||
{
|
||||
SendGetRequest();
|
||||
}
|
||||
else if (e.key.code == KeyCode::P)
|
||||
{
|
||||
SendPostRequest();
|
||||
}
|
||||
else if (e.key.code == KeyCode::U)
|
||||
{
|
||||
SendPutRequest();
|
||||
}
|
||||
else if (e.key.code == KeyCode::D)
|
||||
{
|
||||
SendDeleteRequest();
|
||||
}
|
||||
}
|
||||
|
||||
void SendGetRequest()
|
||||
{
|
||||
// 发送 GET 请求
|
||||
Logger::Instance()->Println(L"Start to send GET request...");
|
||||
|
||||
HttpRequestPtr request = new HttpRequest;
|
||||
// 设置请求 URL
|
||||
request->SetUrl(L"http://httpbin.org/get");
|
||||
// 设置请求类型为 GET
|
||||
request->SetType(HttpRequest::Type::Get);
|
||||
// 设置请求完成后的回调函数
|
||||
request->SetResponseCallback(MakeClosure(this, &Demo5::Complete));
|
||||
|
||||
// 发送 HTTP 请求
|
||||
HttpClient::Instance()->Send(request);
|
||||
}
|
||||
|
||||
void SendPostRequest()
|
||||
{
|
||||
// 发送 POST 请求
|
||||
Logger::Instance()->Println(L"Start to send POST request...");
|
||||
|
||||
// 创建 JSON 格式的 POST 数据
|
||||
Json request_data = {
|
||||
{ L"string", L"test中文" },
|
||||
{ L"boolean", true },
|
||||
{ L"integer", 12 },
|
||||
{ L"float", 3.125 },
|
||||
{ L"array", { 1, 2, 3, 4, 4.5 } },
|
||||
{ L"object", { L"key", L"value" } },
|
||||
};
|
||||
|
||||
HttpRequestPtr request = new HttpRequest;
|
||||
request->SetUrl(L"http://httpbin.org/post");
|
||||
request->SetType(HttpRequest::Type::Post);
|
||||
// 设置 POST 请求的数据
|
||||
request->SetJsonData(request_data);
|
||||
request->SetResponseCallback(MakeClosure(this, &Demo5::Complete));
|
||||
|
||||
HttpClient::Instance()->Send(request);
|
||||
}
|
||||
|
||||
void SendPutRequest()
|
||||
{
|
||||
// 发送 PUT 请求
|
||||
Logger::Instance()->Println(L"Start to send PUT request...");
|
||||
|
||||
// 创建 JSON 格式的 PUT 数据
|
||||
Json request_data = Json::array({ 1, 2, 3 });
|
||||
|
||||
HttpRequestPtr request = new HttpRequest;
|
||||
request->SetUrl(L"http://httpbin.org/put");
|
||||
request->SetType(HttpRequest::Type::Put);
|
||||
// 设置 PUT 请求的数据
|
||||
request->SetJsonData(request_data);
|
||||
request->SetResponseCallback(MakeClosure(this, &Demo5::Complete));
|
||||
|
||||
HttpClient::Instance()->Send(request);
|
||||
}
|
||||
|
||||
void SendDeleteRequest()
|
||||
{
|
||||
// 发送 DELETE 请求
|
||||
Logger::Instance()->Println(L"Start to send DELETE request...");
|
||||
|
||||
HttpRequestPtr request = new HttpRequest;
|
||||
request->SetUrl(L"http://httpbin.org/delete");
|
||||
request->SetType(HttpRequest::Type::Delete);
|
||||
request->SetResponseCallback(MakeClosure(this, &Demo5::Complete));
|
||||
|
||||
HttpClient::Instance()->Send(request);
|
||||
}
|
||||
|
||||
void Complete(HttpRequestPtr request, HttpResponsePtr response)
|
||||
{
|
||||
// 判断请求是否成功
|
||||
if (response->IsSucceed())
|
||||
{
|
||||
try
|
||||
{
|
||||
// 将获取到的数据解析成 JSON 格式
|
||||
Json response_data = Json::parse(response->GetData());
|
||||
Json result = {
|
||||
{L"HttpCode", response->GetResponseCode()},
|
||||
{L"Data", response_data},
|
||||
};
|
||||
|
||||
std::wcout << L"Response: " << std::endl << result.dump(4) << std::endl;
|
||||
}
|
||||
catch (json_exception& e)
|
||||
{
|
||||
std::wcout << L"Parse JSON failed: " << e.what() << std::endl;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// 请求失败时打印错误信息
|
||||
OutputError(response);
|
||||
}
|
||||
}
|
||||
|
||||
void OutputError(HttpResponsePtr response)
|
||||
{
|
||||
// 打印 HTTP 响应结果的状态码和错误信息
|
||||
Json result = {
|
||||
{L"HttpCode", response->GetResponseCode()},
|
||||
{L"Error", response->GetError()},
|
||||
};
|
||||
std::wcout << L"Response: " << std::endl << result.dump(4) << std::endl;
|
||||
}
|
||||
};
|
||||
|
|
@ -1,133 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{45F5738D-CDF2-4024-974D-25B64F9043DE}</ProjectGuid>
|
||||
<RootNamespace>Samples</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<PlatformToolset>$(DefaultPlatformToolset)</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<WholeProgramOptimization>false</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<PlatformToolset>$(DefaultPlatformToolset)</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<OutDir>$(SolutionDir)\output\$(PlatformToolset)\$(Platform)\$(Configuration)\</OutDir>
|
||||
<IntDir>$(SolutionDir)\build\$(PlatformToolset)\$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<OutDir>$(SolutionDir)\output\$(PlatformToolset)\$(Platform)\$(Configuration)\</OutDir>
|
||||
<IntDir>$(SolutionDir)\build\$(PlatformToolset)\$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<AdditionalIncludeDirectories>../../src;</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
</Link>
|
||||
<PreBuildEvent>
|
||||
<Command>
|
||||
xcopy "$(ProjectDir)\res" "$(OutDir)\res\" /D /E /I /F /Y
|
||||
xcopy "$(ProjectDir)..\..\src\kiwano-network\dlls\*.dll" "$(OutDir)" /D /Y
|
||||
</Command>
|
||||
<Message>Copy files</Message>
|
||||
</PreBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<AdditionalIncludeDirectories>../../src;</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
</Link>
|
||||
<PreBuildEvent>
|
||||
<Command>
|
||||
xcopy "$(ProjectDir)\res" "$(OutDir)\res\" /D /E /I /F /Y
|
||||
xcopy "$(ProjectDir)..\..\src\kiwano-network\dlls\*.dll" "$(OutDir)" /D /Y
|
||||
</Command>
|
||||
<Message>Copy files</Message>
|
||||
</PreBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="main.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="common.h" />
|
||||
<ClInclude Include="Demo1.h" />
|
||||
<ClInclude Include="Demo2.h" />
|
||||
<ClInclude Include="Demo3.h" />
|
||||
<ClInclude Include="Demo4.h" />
|
||||
<ClInclude Include="Demo5.h" />
|
||||
<ClInclude Include="resource.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\projects\kiwano-audio.vcxproj">
|
||||
<Project>{1b97937d-8184-426c-be71-29a163dc76c9}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\projects\kiwano-network.vcxproj">
|
||||
<Project>{69dfbe92-c06f-4cf8-9495-ca9bf2e3baf2}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\projects\kiwano.vcxproj">
|
||||
<Project>{ff7f943d-a89c-4e6c-97cf-84f7d8ff8edf}</Project>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="res\index.json" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Xml Include="res\index.xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="Samples.rc" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Image Include="..\..\logo\icon.ico" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
|
|
@ -1,57 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<ClCompile Include="main.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Demo1.h">
|
||||
<Filter>src</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Demo2.h">
|
||||
<Filter>src</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Demo3.h">
|
||||
<Filter>src</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Demo4.h">
|
||||
<Filter>src</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Demo5.h">
|
||||
<Filter>src</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="common.h">
|
||||
<Filter>src</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="resource.h">
|
||||
<Filter>resources</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Filter Include="src">
|
||||
<UniqueIdentifier>{4460eeec-9e2f-46b6-909a-5ff4443075ce}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="resources">
|
||||
<UniqueIdentifier>{04b65e7e-f0ce-4b83-a73e-501913daf790}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Xml Include="res\index.xml">
|
||||
<Filter>resources</Filter>
|
||||
</Xml>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="res\index.json">
|
||||
<Filter>resources</Filter>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Image Include="..\..\logo\icon.ico">
|
||||
<Filter>resources</Filter>
|
||||
</Image>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="Samples.rc">
|
||||
<Filter>resources</Filter>
|
||||
</ResourceCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
// Copyright (C) 2019 Nomango
|
||||
|
||||
#pragma once
|
||||
#include "kiwano/kiwano.h"
|
||||
#include "kiwano-audio/kiwano-audio.h"
|
||||
#include "kiwano-network/kiwano-network.h"
|
||||
|
||||
using namespace kiwano;
|
||||
using namespace kiwano::audio;
|
||||
using namespace kiwano::network;
|
||||
|
||||
const int WINDOW_WIDTH = 640;
|
||||
const int WINDOW_HEIGHT = 480;
|
||||
|
||||
// 栗都속潼묏야
|
||||
extern ResLoader g_Loader;
|
||||
|
|
@ -1,115 +0,0 @@
|
|||
// Copyright (C) 2019 Nomango
|
||||
|
||||
#include "Demo1.h"
|
||||
#include "Demo2.h"
|
||||
#include "Demo3.h"
|
||||
#include "Demo4.h"
|
||||
#include "Demo5.h"
|
||||
#include "resource.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
struct Demo
|
||||
{
|
||||
String title;
|
||||
ScenePtr(*Create)();
|
||||
};
|
||||
|
||||
Demo s_Demos[] = {
|
||||
{ L"动画示例", Demo1::Create },
|
||||
{ L"输入示例", Demo2::Create },
|
||||
{ L"音频播放示例", Demo3::Create },
|
||||
{ L"帧动画示例", Demo4::Create },
|
||||
{ L"网络请求示例", Demo5::Create },
|
||||
};
|
||||
int s_CurrIndex = -1;
|
||||
int s_DemoNum = sizeof(s_Demos) / sizeof(Demo);
|
||||
}
|
||||
|
||||
// 资源加载工具
|
||||
ResLoader g_Loader;
|
||||
|
||||
class DemoApp
|
||||
: public Application
|
||||
{
|
||||
public:
|
||||
DemoApp()
|
||||
{
|
||||
// 使用 Audio 组件
|
||||
Use(Audio::Instance());
|
||||
|
||||
// 使用 HttpClient 组件
|
||||
Use(HttpClient::Instance());
|
||||
|
||||
Options options(L"Kiwano示例程序", WINDOW_WIDTH, WINDOW_HEIGHT, MAKEINTRESOURCE(IDI_ICON1));
|
||||
Init(options);
|
||||
}
|
||||
|
||||
void OnStart() override
|
||||
{
|
||||
// 从 JSON 文件中读取资源信息
|
||||
//g_Loader.LoadFromJsonFile(L"res/index.json");
|
||||
|
||||
// 从 XML 文件中读取资源信息
|
||||
g_Loader.LoadFromXmlFile(L"res/index.xml");
|
||||
|
||||
// 切换到第一个场景
|
||||
ChangeDemoScene(0);
|
||||
}
|
||||
|
||||
void OnDestroy() override
|
||||
{
|
||||
// 退出游戏时销毁资源
|
||||
g_Loader.Destroy();
|
||||
}
|
||||
|
||||
void ChangeDemoScene(int index)
|
||||
{
|
||||
if (s_CurrIndex != index)
|
||||
{
|
||||
s_CurrIndex = index;
|
||||
|
||||
String title = s_Demos[index].title;
|
||||
Window::Instance()->SetTitle(L"Kiwano示例程序 - " + title);
|
||||
|
||||
ScenePtr scene = s_Demos[index].Create();
|
||||
EnterScene(scene);
|
||||
|
||||
// 添加按键监听
|
||||
scene->AddListener(Event::KeyUp, MakeClosure(this, &DemoApp::KeyPressed));
|
||||
|
||||
// 显示提示文字
|
||||
String intro_str = String::format(L"按键 1~%d 可切换示例\n", s_DemoNum);
|
||||
TextPtr intro = new Text(intro_str + title);
|
||||
intro->SetFontSize(16.f);
|
||||
intro->SetPosition(10, 10);
|
||||
scene->AddChild(intro);
|
||||
}
|
||||
}
|
||||
|
||||
void KeyPressed(Event const& evt)
|
||||
{
|
||||
KGE_ASSERT(evt.type == Event::KeyUp);
|
||||
|
||||
if (evt.key.code > KeyCode::Num0 &&
|
||||
evt.key.code <= (KeyCode::Num0 + s_DemoNum))
|
||||
{
|
||||
int index = evt.key.code - KeyCode::Num1;
|
||||
ChangeDemoScene(index);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
int WINAPI wWinMain(_In_ HINSTANCE, _In_opt_ HINSTANCE, _In_ PWSTR, _In_ int)
|
||||
{
|
||||
try
|
||||
{
|
||||
DemoApp app;
|
||||
app.Run();
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
::MessageBoxA(nullptr, e.what(), "An exception has occurred!", MB_ICONERROR | MB_OK);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
Before Width: | Height: | Size: 53 KiB |
|
Before Width: | Height: | Size: 81 KiB |
|
|
@ -1,40 +0,0 @@
|
|||
{
|
||||
"version": "0.1",
|
||||
"path": "./res/",
|
||||
"images": [
|
||||
{
|
||||
"id": "man",
|
||||
"file": "man.png"
|
||||
},
|
||||
{
|
||||
"id": "monster",
|
||||
"file": "akushu.png"
|
||||
},
|
||||
{
|
||||
"id": "forest_bg",
|
||||
"file": "spring_forest.jpg"
|
||||
},
|
||||
{
|
||||
"id": "tiger_running",
|
||||
"files": [
|
||||
"tiger/run/run01.png",
|
||||
"tiger/run/run02.png",
|
||||
"tiger/run/run03.png",
|
||||
"tiger/run/run04.png",
|
||||
"tiger/run/run05.png",
|
||||
"tiger/run/run06.png"
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "tiger_standing",
|
||||
"file": "tiger/stand.png",
|
||||
"rows": 2,
|
||||
"cols": 3
|
||||
},
|
||||
{
|
||||
"id": "Kusanagi",
|
||||
"file": "Kusanagi.gif",
|
||||
"type": "gif"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
<resources>
|
||||
<version>0.1</version>
|
||||
<path>./res/</path>
|
||||
<images>
|
||||
<image id="man" file="man.png" />
|
||||
<image id="monster" file="akushu.png" />
|
||||
<image id="forest_bg" file="spring_forest.jpg" />
|
||||
<image id="tiger_standing" file="tiger/stand.png" rows="2" cols="3" />
|
||||
<image id="tiger_running">
|
||||
<file path="tiger/run/run01.png"/>
|
||||
<file path="tiger/run/run02.png"/>
|
||||
<file path="tiger/run/run03.png"/>
|
||||
<file path="tiger/run/run04.png"/>
|
||||
<file path="tiger/run/run05.png"/>
|
||||
<file path="tiger/run/run06.png"/>
|
||||
</image>
|
||||
<image id="Kusanagi" file="Kusanagi.gif" type="gif" />
|
||||
</images>
|
||||
</resources>
|
||||
|
Before Width: | Height: | Size: 8.6 KiB |
|
Before Width: | Height: | Size: 209 KiB |
|
Before Width: | Height: | Size: 3.7 KiB |
|
Before Width: | Height: | Size: 3.5 KiB |
|
Before Width: | Height: | Size: 3.3 KiB |
|
Before Width: | Height: | Size: 3.5 KiB |
|
Before Width: | Height: | Size: 3.6 KiB |
|
Before Width: | Height: | Size: 3.6 KiB |
|
Before Width: | Height: | Size: 3.5 KiB |
|
Before Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 3.5 KiB |
|
Before Width: | Height: | Size: 3.5 KiB |
|
Before Width: | Height: | Size: 3.5 KiB |
|
Before Width: | Height: | Size: 3.5 KiB |
|
Before Width: | Height: | Size: 3.4 KiB |
|
Before Width: | Height: | Size: 3.4 KiB |
|
|
@ -1,16 +0,0 @@
|
|||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Visual C++ 生成的包含文件。
|
||||
// 供 Samples.rc 使用
|
||||
//
|
||||
#define IDI_ICON1 101
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 102
|
||||
#define _APS_NEXT_COMMAND_VALUE 40001
|
||||
#define _APS_NEXT_CONTROL_VALUE 1001
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
||||
|
|
@ -72,6 +72,9 @@ namespace kiwano
|
|||
};
|
||||
|
||||
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4996)
|
||||
|
||||
// 顺序动作
|
||||
class KGE_API ActionSequence
|
||||
: public ActionGroup
|
||||
|
|
@ -100,4 +103,7 @@ namespace kiwano
|
|||
|
||||
virtual ~ActionSpawn() {}
|
||||
};
|
||||
|
||||
#pragma warning(pop)
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -424,36 +424,84 @@ namespace kiwano
|
|||
// ActionPath
|
||||
//-------------------------------------------------------
|
||||
|
||||
ActionPath::ActionPath(Duration duration, GeometryPtr geo, bool rotating, float start, float end, EaseFunc func)
|
||||
ActionPath::ActionPath(Duration duration, bool rotating, float start, float end, EaseFunc func)
|
||||
: ActionTween(duration, func)
|
||||
, start_(start)
|
||||
, end_(end)
|
||||
, geo_(geo)
|
||||
, rotating_(rotating)
|
||||
, path_beginning_(false)
|
||||
, geo_(nullptr)
|
||||
, geo_sink_(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
ActionPtr ActionPath::Clone() const
|
||||
{
|
||||
return new ActionPath(dur_, geo_, rotating_, start_, end_, ease_func_);
|
||||
ActionPathPtr clone = new ActionPath(dur_, rotating_, start_, end_, ease_func_);
|
||||
if (clone)
|
||||
{
|
||||
clone->SetGeometry(geo_);
|
||||
}
|
||||
return clone;
|
||||
}
|
||||
|
||||
ActionPtr ActionPath::Reverse() const
|
||||
{
|
||||
return new ActionPath(dur_, geo_, rotating_, end_, start_, ease_func_);
|
||||
ActionPathPtr reverse = new ActionPath(dur_, rotating_, end_, start_, ease_func_);
|
||||
if (reverse)
|
||||
{
|
||||
reverse->SetGeometry(geo_);
|
||||
}
|
||||
return reverse;
|
||||
}
|
||||
|
||||
float ActionPath::GetPathLength() const
|
||||
{
|
||||
float length = 0.f;
|
||||
if (geo_)
|
||||
{
|
||||
// no matter it failed or not
|
||||
geo_->ComputeLength(D2D1::Matrix3x2F::Identity(), &length);
|
||||
}
|
||||
return length;
|
||||
}
|
||||
|
||||
bool ActionPath::ComputePointAtLength(float length, Point* point, Vec2* tangent) const
|
||||
{
|
||||
if (geo_)
|
||||
{
|
||||
HRESULT hr = geo_->ComputePointAtLength(
|
||||
length,
|
||||
D2D1::Matrix3x2F::Identity(),
|
||||
DX::ConvertToPoint2F(point),
|
||||
DX::ConvertToPoint2F(tangent)
|
||||
);
|
||||
return SUCCEEDED(hr);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void ActionPath::Init(NodePtr target)
|
||||
{
|
||||
start_pos_ = target->GetPosition();
|
||||
|
||||
if (path_beginning_)
|
||||
{
|
||||
EndPath();
|
||||
}
|
||||
|
||||
if (!geo_)
|
||||
{
|
||||
Complete(target);
|
||||
}
|
||||
}
|
||||
|
||||
void ActionPath::UpdateTween(NodePtr target, float percent)
|
||||
{
|
||||
float length = geo_->GetLength() * std::min(std::max((end_ - start_) * percent + start_, 0.f), 1.f);
|
||||
float length = GetPathLength() * std::min(std::max((end_ - start_) * percent + start_, 0.f), 1.f);
|
||||
|
||||
Point point, tangent;
|
||||
if (geo_->ComputePointAt(length, &point, &tangent))
|
||||
if (ComputePointAtLength(length, &point, &tangent))
|
||||
{
|
||||
target->SetPosition(start_pos_ + point);
|
||||
|
||||
|
|
@ -466,6 +514,123 @@ namespace kiwano
|
|||
}
|
||||
}
|
||||
|
||||
void ActionPath::BeginPath()
|
||||
{
|
||||
if (path_beginning_) return;
|
||||
path_beginning_ = true;
|
||||
|
||||
geo_ = nullptr;
|
||||
geo_sink_ = nullptr;
|
||||
|
||||
auto factory = Renderer::Instance()->GetD2DDeviceResources()->GetFactory();
|
||||
|
||||
ThrowIfFailed(
|
||||
factory->CreatePathGeometry(&geo_)
|
||||
);
|
||||
|
||||
ThrowIfFailed(
|
||||
geo_->Open(&geo_sink_)
|
||||
);
|
||||
|
||||
geo_sink_->BeginFigure(DX::ConvertToPoint2F(Point{ 0, 0 }), D2D1_FIGURE_BEGIN_FILLED);
|
||||
}
|
||||
|
||||
void ActionPath::EndPath(bool closed)
|
||||
{
|
||||
if (!path_beginning_) return;
|
||||
path_beginning_ = false;
|
||||
|
||||
if (geo_sink_)
|
||||
{
|
||||
geo_sink_->EndFigure(closed ? D2D1_FIGURE_END_CLOSED : D2D1_FIGURE_END_OPEN);
|
||||
ThrowIfFailed(
|
||||
geo_sink_->Close()
|
||||
);
|
||||
|
||||
// Clear geometry sink
|
||||
geo_sink_ = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void ActionPath::AddLine(Point const& point)
|
||||
{
|
||||
if (!path_beginning_)
|
||||
{
|
||||
BeginPath();
|
||||
}
|
||||
|
||||
if (geo_sink_)
|
||||
{
|
||||
geo_sink_->AddLine(DX::ConvertToPoint2F(point));
|
||||
}
|
||||
}
|
||||
|
||||
void ActionPath::AddLines(Array<Point> const& points)
|
||||
{
|
||||
if (!path_beginning_)
|
||||
{
|
||||
BeginPath();
|
||||
}
|
||||
|
||||
if (geo_sink_ && !points.empty())
|
||||
{
|
||||
geo_sink_->AddLines(
|
||||
reinterpret_cast<const D2D_POINT_2F*>(&points[0]),
|
||||
static_cast<UINT32>(points.size())
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void ActionPath::AddBezier(Point const& point1, Point const& point2, Point const& point3)
|
||||
{
|
||||
if (!path_beginning_)
|
||||
{
|
||||
BeginPath();
|
||||
}
|
||||
|
||||
if (geo_sink_)
|
||||
{
|
||||
geo_sink_->AddBezier(
|
||||
D2D1::BezierSegment(
|
||||
DX::ConvertToPoint2F(point1),
|
||||
DX::ConvertToPoint2F(point2),
|
||||
DX::ConvertToPoint2F(point3)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void ActionPath::AddArc(Point const& point, Size const& radius, float rotation, bool clockwise, bool is_small)
|
||||
{
|
||||
if (!path_beginning_)
|
||||
{
|
||||
BeginPath();
|
||||
}
|
||||
|
||||
if (geo_sink_)
|
||||
{
|
||||
geo_sink_->AddArc(
|
||||
D2D1::ArcSegment(
|
||||
DX::ConvertToPoint2F(point),
|
||||
DX::ConvertToSizeF(radius),
|
||||
rotation,
|
||||
clockwise ? D2D1_SWEEP_DIRECTION_CLOCKWISE : D2D1_SWEEP_DIRECTION_COUNTER_CLOCKWISE,
|
||||
is_small ? D2D1_ARC_SIZE_SMALL : D2D1_ARC_SIZE_LARGE
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void ActionPath::ClearPath()
|
||||
{
|
||||
if (path_beginning_)
|
||||
{
|
||||
EndPath();
|
||||
}
|
||||
|
||||
geo_sink_ = nullptr;
|
||||
geo_ = nullptr;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------
|
||||
// ActionCustom
|
||||
|
|
|
|||
|
|
@ -20,8 +20,8 @@
|
|||
|
||||
#pragma once
|
||||
#include "Action.h"
|
||||
#include "Geometry.h" // ActionPath
|
||||
#include "../base/logs.h"
|
||||
#include "../renderer/render.h" // ID2D1PathGeometry, ID2D1GeometrySink
|
||||
|
||||
namespace kiwano
|
||||
{
|
||||
|
|
@ -419,7 +419,6 @@ namespace kiwano
|
|||
public:
|
||||
ActionPath(
|
||||
Duration duration, /* 持续时长 */
|
||||
GeometryPtr geo, /* 섯부暠近 */
|
||||
bool rotating = false, /* 沿路径切线方向旋转 */
|
||||
float start = 0.f, /* 起点 */
|
||||
float end = 1.f, /* 终点 */
|
||||
|
|
@ -432,17 +431,69 @@ namespace kiwano
|
|||
// 获取该动作的倒转
|
||||
ActionPtr Reverse() const override;
|
||||
|
||||
// 开始添加路径
|
||||
void BeginPath();
|
||||
|
||||
// 结束路径
|
||||
void EndPath(
|
||||
bool closed = false /* 路径是否闭合 */
|
||||
);
|
||||
|
||||
// 添加一条线段
|
||||
void AddLine(
|
||||
Point const& point /* 端点 */
|
||||
);
|
||||
|
||||
// 添加多条线段
|
||||
void AddLines(
|
||||
Array<Point> const& points
|
||||
);
|
||||
|
||||
// 添加一条三次方贝塞尔曲线
|
||||
void AddBezier(
|
||||
Point const& point1, /* 贝塞尔曲线的第一个控制点 */
|
||||
Point const& point2, /* 贝塞尔曲线的第二个控制点 */
|
||||
Point const& point3 /* 贝塞尔曲线的终点 */
|
||||
);
|
||||
|
||||
// 添加弧线
|
||||
void AddArc(
|
||||
Point const& point, /* 终点 */
|
||||
Size const& radius, /* 椭圆半径 */
|
||||
float rotation, /* 椭圆旋转角度 */
|
||||
bool clockwise = true, /* 顺时针 or 逆时针 */
|
||||
bool is_small = true /* 是否取小于 180° 的弧 */
|
||||
);
|
||||
|
||||
// 清除路径
|
||||
void ClearPath();
|
||||
|
||||
// 获取路径长度
|
||||
float GetPathLength() const;
|
||||
|
||||
// 计算当前路径上指定点坐标和切线
|
||||
bool ComputePointAtLength(float length, Point* point, Vec2* tangent) const;
|
||||
|
||||
// 获取几何路径
|
||||
inline ComPtr<ID2D1PathGeometry> GetGeometry() const { return geo_; }
|
||||
|
||||
// 设置几何路径
|
||||
inline void SetGeometry(ComPtr<ID2D1PathGeometry> geo) { geo_ = geo; }
|
||||
|
||||
protected:
|
||||
void Init(NodePtr target) override;
|
||||
|
||||
void UpdateTween(NodePtr target, float percent) override;
|
||||
|
||||
protected:
|
||||
bool rotating_;
|
||||
float start_;
|
||||
float end_;
|
||||
Point start_pos_;
|
||||
GeometryPtr geo_;
|
||||
bool path_beginning_;
|
||||
bool rotating_;
|
||||
float start_;
|
||||
float end_;
|
||||
Point start_pos_;
|
||||
|
||||
ComPtr<ID2D1PathGeometry> geo_;
|
||||
ComPtr<ID2D1GeometrySink> geo_sink_;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@
|
|||
|
||||
#include "Canvas.h"
|
||||
#include "Image.h"
|
||||
#include "Geometry.h"
|
||||
#include "../base/logs.h"
|
||||
#include "../renderer/render.h"
|
||||
|
||||
|
|
@ -298,20 +297,6 @@ namespace kiwano
|
|||
);
|
||||
}
|
||||
|
||||
void Canvas::DrawGeometry(GeometryPtr geo)
|
||||
{
|
||||
if (geo && geo->geo_)
|
||||
{
|
||||
render_target_->DrawGeometry(
|
||||
geo->geo_.Get(),
|
||||
stroke_brush_.Get(),
|
||||
stroke_width_,
|
||||
outline_join_style_.Get()
|
||||
);
|
||||
cache_expired_ = true;
|
||||
}
|
||||
}
|
||||
|
||||
void Canvas::FillCircle(const Point & center, float radius)
|
||||
{
|
||||
render_target_->FillEllipse(
|
||||
|
|
@ -376,18 +361,6 @@ namespace kiwano
|
|||
cache_expired_ = true;
|
||||
}
|
||||
|
||||
void Canvas::FillGeometry(GeometryPtr geo)
|
||||
{
|
||||
if (geo && geo->geo_)
|
||||
{
|
||||
render_target_->FillGeometry(
|
||||
geo->geo_.Get(),
|
||||
fill_brush_.Get()
|
||||
);
|
||||
cache_expired_ = true;
|
||||
}
|
||||
}
|
||||
|
||||
void Canvas::BeginPath(Point const& begin_pos)
|
||||
{
|
||||
current_geometry_ = nullptr;
|
||||
|
|
@ -508,4 +481,4 @@ namespace kiwano
|
|||
return bitmap_cached_;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -95,11 +95,6 @@ namespace kiwano
|
|||
Point const& point /* 文字位置 */
|
||||
);
|
||||
|
||||
// 뺌섯부暠近긋움
|
||||
void DrawGeometry(
|
||||
GeometryPtr geo
|
||||
);
|
||||
|
||||
// 填充圆形
|
||||
void FillCircle(
|
||||
const Point& center,
|
||||
|
|
@ -125,11 +120,6 @@ namespace kiwano
|
|||
float radius_y
|
||||
);
|
||||
|
||||
// 輕념섯부暠近
|
||||
void FillGeometry(
|
||||
GeometryPtr geo
|
||||
);
|
||||
|
||||
// 开始绘制路径
|
||||
void BeginPath(
|
||||
Point const& begin_pos /* 路径起始点 */
|
||||
|
|
@ -240,4 +230,4 @@ namespace kiwano
|
|||
mutable bool cache_expired_;
|
||||
mutable ComPtr<ID2D1Bitmap> bitmap_cached_;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,87 +0,0 @@
|
|||
// Copyright (c) 2016-2018 Kiwano - Nomango
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#include "GeometryNode.h"
|
||||
#include "../renderer/render.h"
|
||||
|
||||
namespace kiwano
|
||||
{
|
||||
GeometryNode::GeometryNode()
|
||||
: fill_color_(Color::White)
|
||||
, stroke_color_(Color(Color::Black, 0))
|
||||
, stroke_width_(1.f)
|
||||
, outline_join_(StrokeStyle::Miter)
|
||||
{
|
||||
}
|
||||
|
||||
GeometryNode::GeometryNode(GeometryPtr geometry)
|
||||
: GeometryNode()
|
||||
{
|
||||
SetGeometry(geometry);
|
||||
}
|
||||
|
||||
GeometryNode::~GeometryNode()
|
||||
{
|
||||
}
|
||||
|
||||
void GeometryNode::SetGeometry(GeometryPtr geometry)
|
||||
{
|
||||
geometry_ = geometry;
|
||||
}
|
||||
|
||||
void GeometryNode::SetFillColor(const Color & color)
|
||||
{
|
||||
fill_color_ = color;
|
||||
}
|
||||
|
||||
void GeometryNode::SetStrokeColor(const Color & color)
|
||||
{
|
||||
stroke_color_ = color;
|
||||
}
|
||||
|
||||
void GeometryNode::SetStrokeWidth(float width)
|
||||
{
|
||||
stroke_width_ = std::max(width, 0.f);
|
||||
}
|
||||
|
||||
void GeometryNode::SetOutlineJoinStyle(StrokeStyle outline_join)
|
||||
{
|
||||
outline_join_ = outline_join;
|
||||
}
|
||||
|
||||
void GeometryNode::OnRender()
|
||||
{
|
||||
if (geometry_ && geometry_->geo_)
|
||||
{
|
||||
Renderer::Instance()->FillGeometry(
|
||||
geometry_->geo_.Get(),
|
||||
fill_color_
|
||||
);
|
||||
|
||||
Renderer::Instance()->DrawGeometry(
|
||||
geometry_->geo_,
|
||||
stroke_color_,
|
||||
stroke_width_,
|
||||
outline_join_
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,89 +0,0 @@
|
|||
// Copyright (c) 2016-2018 Kiwano - Nomango
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
#include "Geometry.h"
|
||||
#include "Node.h"
|
||||
|
||||
namespace kiwano
|
||||
{
|
||||
// ¼¸ºÎͼÐÎ
|
||||
class KGE_API GeometryNode
|
||||
: public VisualNode
|
||||
{
|
||||
public:
|
||||
GeometryNode();
|
||||
|
||||
GeometryNode(
|
||||
GeometryPtr geometry
|
||||
);
|
||||
|
||||
virtual ~GeometryNode();
|
||||
|
||||
// ÉèÖÃÐÎ×´
|
||||
void SetGeometry(
|
||||
GeometryPtr geometry
|
||||
);
|
||||
|
||||
// ÉèÖÃÌî³äÑÕÉ«
|
||||
void SetFillColor(
|
||||
const Color& color
|
||||
);
|
||||
|
||||
// ÉèÖÃÏßÌõÑÕÉ«
|
||||
void SetStrokeColor(
|
||||
const Color& color
|
||||
);
|
||||
|
||||
// ÉèÖÃÏßÌõ¿í¶È
|
||||
void SetStrokeWidth(
|
||||
float width
|
||||
);
|
||||
|
||||
// ÉèÖÃÏßÌõÏཻÑùʽ
|
||||
void SetOutlineJoinStyle(
|
||||
StrokeStyle outline_join
|
||||
);
|
||||
|
||||
// »ñÈ¡ÐÎ×´
|
||||
GeometryPtr GetGeometry() const { return geometry_; }
|
||||
|
||||
// »ñÈ¡Ìî³äÑÕÉ«
|
||||
Color GetFillColor() const { return fill_color_; }
|
||||
|
||||
// »ñÈ¡ÏßÌõÑÕÉ«
|
||||
Color GetStrokeColor() const { return stroke_color_; }
|
||||
|
||||
// »ñÈ¡ÏßÌõ¿í¶È
|
||||
float GetStrokeWidth() const { return stroke_width_; }
|
||||
|
||||
// »ñÈ¡ÏßÌõÏཻÑùʽ
|
||||
StrokeStyle SetOutlineJoinStyle() const { return outline_join_; }
|
||||
|
||||
void OnRender() override;
|
||||
|
||||
protected:
|
||||
Color fill_color_;
|
||||
Color stroke_color_;
|
||||
float stroke_width_;
|
||||
StrokeStyle outline_join_;
|
||||
GeometryPtr geometry_;
|
||||
};
|
||||
}
|
||||
|
|
@ -18,25 +18,30 @@
|
|||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#include "Geometry.h"
|
||||
#include "../renderer/render.h"
|
||||
#include "ShapeNode.h"
|
||||
#include "../base/logs.h"
|
||||
|
||||
namespace kiwano
|
||||
{
|
||||
//-------------------------------------------------------
|
||||
// Geometry
|
||||
//-------------------------------------------------------
|
||||
|
||||
Geometry::Geometry()
|
||||
ShapeNode::ShapeNode()
|
||||
: fill_color_(Color::White)
|
||||
, stroke_color_(Color(Color::Black, 0))
|
||||
, stroke_width_(1.f)
|
||||
, outline_join_(StrokeStyle::Miter)
|
||||
{
|
||||
}
|
||||
|
||||
Geometry::~Geometry()
|
||||
ShapeNode::ShapeNode(ComPtr<ID2D1Geometry> geometry)
|
||||
: ShapeNode()
|
||||
{
|
||||
SetGeometry(geometry);
|
||||
}
|
||||
|
||||
ShapeNode::~ShapeNode()
|
||||
{
|
||||
}
|
||||
|
||||
Rect Geometry::GetBoundingBox()
|
||||
Rect ShapeNode::GetBoundingBox()
|
||||
{
|
||||
if (!geo_)
|
||||
return Rect{};
|
||||
|
|
@ -47,7 +52,7 @@ namespace kiwano
|
|||
return Rect{ rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top };
|
||||
}
|
||||
|
||||
float Geometry::GetLength()
|
||||
float ShapeNode::GetLength()
|
||||
{
|
||||
float length = 0.f;
|
||||
if (geo_)
|
||||
|
|
@ -58,28 +63,23 @@ namespace kiwano
|
|||
return length;
|
||||
}
|
||||
|
||||
bool Geometry::ComputePointAt(float length, Point* point, Point* tangent)
|
||||
bool ShapeNode::ComputePointAtLength(float length, Point& point, Vec2& tangent)
|
||||
{
|
||||
if (geo_)
|
||||
{
|
||||
D2D1_POINT_2F point_tmp, tangent_tmp;
|
||||
if (SUCCEEDED(geo_->ComputePointAtLength(
|
||||
length,
|
||||
D2D1::Matrix3x2F::Identity(),
|
||||
&point_tmp,
|
||||
&tangent_tmp)))
|
||||
DX::ConvertToPoint2F(&point),
|
||||
DX::ConvertToPoint2F(&tangent))))
|
||||
{
|
||||
(*point).x = point_tmp.x;
|
||||
(*point).y = point_tmp.y;
|
||||
(*tangent).x = tangent_tmp.x;
|
||||
(*tangent).y = tangent_tmp.y;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
float Geometry::ComputeArea()
|
||||
float ShapeNode::ComputeArea()
|
||||
{
|
||||
if (!geo_)
|
||||
return 0.f;
|
||||
|
|
@ -90,7 +90,7 @@ namespace kiwano
|
|||
return area;
|
||||
}
|
||||
|
||||
bool Geometry::ContainsPoint(Point const & point)
|
||||
bool ShapeNode::ContainsPoint(Point const& point)
|
||||
{
|
||||
if (!geo_)
|
||||
return false;
|
||||
|
|
@ -105,25 +105,62 @@ namespace kiwano
|
|||
return !!ret;
|
||||
}
|
||||
|
||||
void ShapeNode::SetFillColor(const Color & color)
|
||||
{
|
||||
fill_color_ = color;
|
||||
}
|
||||
|
||||
void ShapeNode::SetStrokeColor(const Color & color)
|
||||
{
|
||||
stroke_color_ = color;
|
||||
}
|
||||
|
||||
void ShapeNode::SetStrokeWidth(float width)
|
||||
{
|
||||
stroke_width_ = std::max(width, 0.f);
|
||||
}
|
||||
|
||||
void ShapeNode::SetOutlineJoinStyle(StrokeStyle outline_join)
|
||||
{
|
||||
outline_join_ = outline_join;
|
||||
}
|
||||
|
||||
void ShapeNode::OnRender()
|
||||
{
|
||||
if (geo_)
|
||||
{
|
||||
Renderer::Instance()->FillGeometry(
|
||||
geo_,
|
||||
fill_color_
|
||||
);
|
||||
|
||||
Renderer::Instance()->DrawGeometry(
|
||||
geo_,
|
||||
stroke_color_,
|
||||
stroke_width_,
|
||||
outline_join_
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------
|
||||
// LineGeometry
|
||||
// LineNode
|
||||
//-------------------------------------------------------
|
||||
|
||||
LineGeometry::LineGeometry()
|
||||
LineNode::LineNode()
|
||||
{
|
||||
}
|
||||
|
||||
LineGeometry::LineGeometry(Point const & begin, Point const & end)
|
||||
LineNode::LineNode(Point const& begin, Point const& end)
|
||||
{
|
||||
SetLine(begin, end);
|
||||
}
|
||||
|
||||
LineGeometry::~LineGeometry()
|
||||
LineNode::~LineNode()
|
||||
{
|
||||
}
|
||||
|
||||
void LineGeometry::SetLine(Point const & begin, Point const & end)
|
||||
void LineNode::SetLine(Point const& begin, Point const& end)
|
||||
{
|
||||
ComPtr<ID2D1PathGeometry> path_geo;
|
||||
ComPtr<ID2D1GeometrySink> path_sink;
|
||||
|
|
@ -149,40 +186,40 @@ namespace kiwano
|
|||
}
|
||||
}
|
||||
|
||||
void LineGeometry::SetBegin(Point const & begin)
|
||||
void LineNode::SetBegin(Point const& begin)
|
||||
{
|
||||
SetLine(begin, end_);
|
||||
}
|
||||
|
||||
void LineGeometry::SetEnd(Point const & end)
|
||||
void LineNode::SetEnd(Point const& end)
|
||||
{
|
||||
SetLine(begin_, end);
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------
|
||||
// RectangleGeometry
|
||||
// RectNode
|
||||
//-------------------------------------------------------
|
||||
|
||||
RectangleGeometry::RectangleGeometry()
|
||||
RectNode::RectNode()
|
||||
{
|
||||
}
|
||||
|
||||
RectangleGeometry::RectangleGeometry(Rect const & rect)
|
||||
RectNode::RectNode(Rect const& rect)
|
||||
{
|
||||
SetRect(rect);
|
||||
}
|
||||
|
||||
RectangleGeometry::RectangleGeometry(Point const & left_top, Size const & size)
|
||||
RectNode::RectNode(Point const& left_top, Size const& size)
|
||||
{
|
||||
SetRect(Rect{ left_top, size });
|
||||
}
|
||||
|
||||
RectangleGeometry::~RectangleGeometry()
|
||||
RectNode::~RectNode()
|
||||
{
|
||||
}
|
||||
|
||||
void RectangleGeometry::SetRect(Rect const & rect)
|
||||
void RectNode::SetRect(Rect const& rect)
|
||||
{
|
||||
ComPtr<ID2D1RectangleGeometry> geo;
|
||||
auto factory = Renderer::Instance()->GetD2DDeviceResources()->GetFactory();
|
||||
|
|
@ -196,230 +233,35 @@ namespace kiwano
|
|||
|
||||
|
||||
//-------------------------------------------------------
|
||||
// CircleGeometry
|
||||
// RoundedRectNode
|
||||
//-------------------------------------------------------
|
||||
|
||||
CircleGeometry::CircleGeometry()
|
||||
: radius_(0.f)
|
||||
{
|
||||
}
|
||||
|
||||
CircleGeometry::CircleGeometry(Point const & center, float radius)
|
||||
{
|
||||
SetCircle(center, radius);
|
||||
}
|
||||
|
||||
CircleGeometry::~CircleGeometry()
|
||||
{
|
||||
}
|
||||
|
||||
void CircleGeometry::SetRadius(float radius)
|
||||
{
|
||||
SetCircle(center_, radius);
|
||||
}
|
||||
|
||||
void CircleGeometry::SetCenter(Point const & center)
|
||||
{
|
||||
SetCircle(center, radius_);
|
||||
}
|
||||
|
||||
void CircleGeometry::SetCircle(Point const & center, float radius)
|
||||
{
|
||||
ComPtr<ID2D1EllipseGeometry> geo;
|
||||
auto factory = Renderer::Instance()->GetD2DDeviceResources()->GetFactory();
|
||||
|
||||
if (SUCCEEDED(factory->CreateEllipseGeometry(
|
||||
D2D1::Ellipse(
|
||||
DX::ConvertToPoint2F(center),
|
||||
radius,
|
||||
radius),
|
||||
&geo)))
|
||||
{
|
||||
geo_ = geo;
|
||||
center_ = center;
|
||||
radius_ = radius;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------
|
||||
// EllipseGeometry
|
||||
//-------------------------------------------------------
|
||||
|
||||
EllipseGeometry::EllipseGeometry()
|
||||
RoundedRectNode::RoundedRectNode()
|
||||
: radius_x_(0.f)
|
||||
, radius_y_(0.f)
|
||||
{
|
||||
}
|
||||
|
||||
EllipseGeometry::EllipseGeometry(Point const & center, float radius_x, float radius_y)
|
||||
{
|
||||
SetEllipse(center, radius_x, radius_y);
|
||||
}
|
||||
|
||||
EllipseGeometry::~EllipseGeometry()
|
||||
{
|
||||
}
|
||||
|
||||
void EllipseGeometry::SetRadius(float radius_x, float radius_y)
|
||||
{
|
||||
SetEllipse(center_, radius_x, radius_y);
|
||||
}
|
||||
|
||||
void EllipseGeometry::SetCenter(Point const & center)
|
||||
{
|
||||
SetEllipse(center, radius_x_, radius_y_);
|
||||
}
|
||||
|
||||
void EllipseGeometry::SetEllipse(Point const & center, float radius_x, float radius_y)
|
||||
{
|
||||
ComPtr<ID2D1EllipseGeometry> geo;
|
||||
auto factory = Renderer::Instance()->GetD2DDeviceResources()->GetFactory();
|
||||
|
||||
if (SUCCEEDED(factory->CreateEllipseGeometry(
|
||||
D2D1::Ellipse(
|
||||
DX::ConvertToPoint2F(center),
|
||||
radius_x,
|
||||
radius_y),
|
||||
&geo)))
|
||||
{
|
||||
geo_ = geo;
|
||||
radius_x_ = radius_x;
|
||||
radius_y_ = radius_y;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------
|
||||
// PathGeometry
|
||||
//-------------------------------------------------------
|
||||
|
||||
PathGeometry::PathGeometry()
|
||||
{
|
||||
}
|
||||
|
||||
PathGeometry::~PathGeometry()
|
||||
{
|
||||
}
|
||||
|
||||
void PathGeometry::BeginPath(Point const& begin_pos)
|
||||
{
|
||||
current_geometry_ = nullptr;
|
||||
|
||||
auto factory = Renderer::Instance()->GetD2DDeviceResources()->GetFactory();
|
||||
|
||||
ThrowIfFailed(
|
||||
factory->CreatePathGeometry(¤t_geometry_)
|
||||
);
|
||||
|
||||
ThrowIfFailed(
|
||||
current_geometry_->Open(¤t_sink_)
|
||||
);
|
||||
|
||||
current_sink_->BeginFigure(DX::ConvertToPoint2F(begin_pos), D2D1_FIGURE_BEGIN_FILLED);
|
||||
}
|
||||
|
||||
void PathGeometry::EndPath(bool closed)
|
||||
{
|
||||
if (current_sink_)
|
||||
{
|
||||
current_sink_->EndFigure(closed ? D2D1_FIGURE_END_CLOSED : D2D1_FIGURE_END_OPEN);
|
||||
ThrowIfFailed(
|
||||
current_sink_->Close()
|
||||
);
|
||||
|
||||
geo_ = current_geometry_;
|
||||
|
||||
current_sink_ = nullptr;
|
||||
current_geometry_ = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void PathGeometry::AddLine(Point const & point)
|
||||
{
|
||||
if (current_sink_)
|
||||
current_sink_->AddLine(DX::ConvertToPoint2F(point));
|
||||
}
|
||||
|
||||
void PathGeometry::AddLines(Array<Point> const& points)
|
||||
{
|
||||
if (current_sink_ && !points.empty())
|
||||
{
|
||||
current_sink_->AddLines(
|
||||
reinterpret_cast<const D2D_POINT_2F*>(&points[0]),
|
||||
static_cast<UINT32>(points.size())
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void PathGeometry::AddBezier(Point const & point1, Point const & point2, Point const & point3)
|
||||
{
|
||||
if (current_sink_)
|
||||
{
|
||||
current_sink_->AddBezier(
|
||||
D2D1::BezierSegment(
|
||||
DX::ConvertToPoint2F(point1),
|
||||
DX::ConvertToPoint2F(point2),
|
||||
DX::ConvertToPoint2F(point3)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void PathGeometry::AddArc(Point const & point, Size const & radius, float rotation, bool clockwise, bool is_small)
|
||||
{
|
||||
if (current_sink_)
|
||||
{
|
||||
current_sink_->AddArc(
|
||||
D2D1::ArcSegment(
|
||||
DX::ConvertToPoint2F(point),
|
||||
DX::ConvertToSizeF(radius),
|
||||
rotation,
|
||||
clockwise ? D2D1_SWEEP_DIRECTION_CLOCKWISE : D2D1_SWEEP_DIRECTION_COUNTER_CLOCKWISE,
|
||||
is_small ? D2D1_ARC_SIZE_SMALL : D2D1_ARC_SIZE_LARGE
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void PathGeometry::ClearPath()
|
||||
{
|
||||
geo_ = nullptr;
|
||||
current_sink_ = nullptr;
|
||||
current_geometry_ = nullptr;
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------
|
||||
// RoundedRectGeometry
|
||||
//-------------------------------------------------------
|
||||
|
||||
RoundedRectGeometry::RoundedRectGeometry()
|
||||
: radius_x_(0.f)
|
||||
, radius_y_(0.f)
|
||||
{
|
||||
}
|
||||
|
||||
RoundedRectGeometry::RoundedRectGeometry(Rect const & rect, float radius_x, float radius_y)
|
||||
RoundedRectNode::RoundedRectNode(Rect const& rect, float radius_x, float radius_y)
|
||||
{
|
||||
SetRoundedRect(rect, radius_x, radius_y);
|
||||
}
|
||||
|
||||
RoundedRectGeometry::~RoundedRectGeometry()
|
||||
RoundedRectNode::~RoundedRectNode()
|
||||
{
|
||||
}
|
||||
|
||||
void RoundedRectGeometry::SetRadius(float radius_x, float radius_y)
|
||||
void RoundedRectNode::SetRadius(float radius_x, float radius_y)
|
||||
{
|
||||
SetRoundedRect(rect_, radius_x, radius_y);
|
||||
}
|
||||
|
||||
void RoundedRectGeometry::SetRect(Rect const & rect)
|
||||
void RoundedRectNode::SetRect(Rect const& rect)
|
||||
{
|
||||
SetRoundedRect(rect, radius_x_, radius_y_);
|
||||
}
|
||||
|
||||
void RoundedRectGeometry::SetRoundedRect(Rect const & rect, float radius_x, float radius_y)
|
||||
void RoundedRectNode::SetRoundedRect(Rect const& rect, float radius_x, float radius_y)
|
||||
{
|
||||
ComPtr<ID2D1RoundedRectangleGeometry> geo;
|
||||
auto factory = Renderer::Instance()->GetD2DDeviceResources()->GetFactory();
|
||||
|
|
@ -439,4 +281,199 @@ namespace kiwano
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//-------------------------------------------------------
|
||||
// CircleNode
|
||||
//-------------------------------------------------------
|
||||
|
||||
CircleNode::CircleNode()
|
||||
: radius_(0.f)
|
||||
{
|
||||
}
|
||||
|
||||
CircleNode::CircleNode(Point const& center, float radius)
|
||||
{
|
||||
SetCircle(center, radius);
|
||||
}
|
||||
|
||||
CircleNode::~CircleNode()
|
||||
{
|
||||
}
|
||||
|
||||
void CircleNode::SetRadius(float radius)
|
||||
{
|
||||
SetCircle(center_, radius);
|
||||
}
|
||||
|
||||
void CircleNode::SetCenter(Point const& center)
|
||||
{
|
||||
SetCircle(center, radius_);
|
||||
}
|
||||
|
||||
void CircleNode::SetCircle(Point const& center, float radius)
|
||||
{
|
||||
ComPtr<ID2D1EllipseGeometry> geo;
|
||||
auto factory = Renderer::Instance()->GetD2DDeviceResources()->GetFactory();
|
||||
|
||||
if (SUCCEEDED(factory->CreateEllipseGeometry(
|
||||
D2D1::Ellipse(
|
||||
DX::ConvertToPoint2F(center),
|
||||
radius,
|
||||
radius),
|
||||
&geo)))
|
||||
{
|
||||
geo_ = geo;
|
||||
center_ = center;
|
||||
radius_ = radius;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------
|
||||
// EllipseNode
|
||||
//-------------------------------------------------------
|
||||
|
||||
EllipseNode::EllipseNode()
|
||||
: radius_x_(0.f)
|
||||
, radius_y_(0.f)
|
||||
{
|
||||
}
|
||||
|
||||
EllipseNode::EllipseNode(Point const& center, float radius_x, float radius_y)
|
||||
{
|
||||
SetEllipse(center, radius_x, radius_y);
|
||||
}
|
||||
|
||||
EllipseNode::~EllipseNode()
|
||||
{
|
||||
}
|
||||
|
||||
void EllipseNode::SetRadius(float radius_x, float radius_y)
|
||||
{
|
||||
SetEllipse(center_, radius_x, radius_y);
|
||||
}
|
||||
|
||||
void EllipseNode::SetCenter(Point const& center)
|
||||
{
|
||||
SetEllipse(center, radius_x_, radius_y_);
|
||||
}
|
||||
|
||||
void EllipseNode::SetEllipse(Point const& center, float radius_x, float radius_y)
|
||||
{
|
||||
ComPtr<ID2D1EllipseGeometry> geo;
|
||||
auto factory = Renderer::Instance()->GetD2DDeviceResources()->GetFactory();
|
||||
|
||||
if (SUCCEEDED(factory->CreateEllipseGeometry(
|
||||
D2D1::Ellipse(
|
||||
DX::ConvertToPoint2F(center),
|
||||
radius_x,
|
||||
radius_y),
|
||||
&geo)))
|
||||
{
|
||||
geo_ = geo;
|
||||
radius_x_ = radius_x;
|
||||
radius_y_ = radius_y;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------
|
||||
// PathNode
|
||||
//-------------------------------------------------------
|
||||
|
||||
PathNode::PathNode()
|
||||
{
|
||||
}
|
||||
|
||||
PathNode::~PathNode()
|
||||
{
|
||||
}
|
||||
|
||||
void PathNode::BeginPath(Point const& begin_pos)
|
||||
{
|
||||
current_geometry_ = nullptr;
|
||||
|
||||
auto factory = Renderer::Instance()->GetD2DDeviceResources()->GetFactory();
|
||||
|
||||
ThrowIfFailed(
|
||||
factory->CreatePathGeometry(¤t_geometry_)
|
||||
);
|
||||
|
||||
ThrowIfFailed(
|
||||
current_geometry_->Open(¤t_sink_)
|
||||
);
|
||||
|
||||
current_sink_->BeginFigure(DX::ConvertToPoint2F(begin_pos), D2D1_FIGURE_BEGIN_FILLED);
|
||||
}
|
||||
|
||||
void PathNode::EndPath(bool closed)
|
||||
{
|
||||
if (current_sink_)
|
||||
{
|
||||
current_sink_->EndFigure(closed ? D2D1_FIGURE_END_CLOSED : D2D1_FIGURE_END_OPEN);
|
||||
ThrowIfFailed(
|
||||
current_sink_->Close()
|
||||
);
|
||||
|
||||
geo_ = current_geometry_;
|
||||
|
||||
current_sink_ = nullptr;
|
||||
current_geometry_ = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void PathNode::AddLine(Point const& point)
|
||||
{
|
||||
if (current_sink_)
|
||||
current_sink_->AddLine(DX::ConvertToPoint2F(point));
|
||||
}
|
||||
|
||||
void PathNode::AddLines(Array<Point> const& points)
|
||||
{
|
||||
if (current_sink_ && !points.empty())
|
||||
{
|
||||
current_sink_->AddLines(
|
||||
reinterpret_cast<const D2D_POINT_2F*>(&points[0]),
|
||||
static_cast<UINT32>(points.size())
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void PathNode::AddBezier(Point const& point1, Point const& point2, Point const& point3)
|
||||
{
|
||||
if (current_sink_)
|
||||
{
|
||||
current_sink_->AddBezier(
|
||||
D2D1::BezierSegment(
|
||||
DX::ConvertToPoint2F(point1),
|
||||
DX::ConvertToPoint2F(point2),
|
||||
DX::ConvertToPoint2F(point3)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void PathNode::AddArc(Point const& point, Size const& radius, float rotation, bool clockwise, bool is_small)
|
||||
{
|
||||
if (current_sink_)
|
||||
{
|
||||
current_sink_->AddArc(
|
||||
D2D1::ArcSegment(
|
||||
DX::ConvertToPoint2F(point),
|
||||
DX::ConvertToSizeF(radius),
|
||||
rotation,
|
||||
clockwise ? D2D1_SWEEP_DIRECTION_CLOCKWISE : D2D1_SWEEP_DIRECTION_COUNTER_CLOCKWISE,
|
||||
is_small ? D2D1_ARC_SIZE_SMALL : D2D1_ARC_SIZE_LARGE
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void PathNode::ClearPath()
|
||||
{
|
||||
geo_ = nullptr;
|
||||
current_sink_ = nullptr;
|
||||
current_geometry_ = nullptr;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -19,22 +19,35 @@
|
|||
// THE SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
#include "include-forwards.h"
|
||||
#include <d2d1.h>
|
||||
#include "Node.h"
|
||||
#include "../renderer/render.h" // ID2D1Geometry
|
||||
|
||||
namespace kiwano
|
||||
{
|
||||
// 섯부녜蹶
|
||||
class KGE_API Geometry
|
||||
: public Object
|
||||
// 二维图形节点
|
||||
class KGE_API ShapeNode
|
||||
: public VisualNode
|
||||
{
|
||||
friend class Canvas;
|
||||
friend class GeometryNode;
|
||||
|
||||
public:
|
||||
Geometry();
|
||||
ShapeNode();
|
||||
|
||||
virtual ~Geometry();
|
||||
ShapeNode(
|
||||
ComPtr<ID2D1Geometry> geometry
|
||||
);
|
||||
|
||||
virtual ~ShapeNode();
|
||||
|
||||
// 获取填充颜色
|
||||
Color GetFillColor() const { return fill_color_; }
|
||||
|
||||
// 获取线条颜色
|
||||
Color GetStrokeColor() const { return stroke_color_; }
|
||||
|
||||
// 获取线条宽度
|
||||
float GetStrokeWidth() const { return stroke_width_; }
|
||||
|
||||
// 获取线条相交样式
|
||||
StrokeStyle SetOutlineJoinStyle() const { return outline_join_; }
|
||||
|
||||
// 获取外切包围盒
|
||||
Rect GetBoundingBox();
|
||||
|
|
@ -47,34 +60,66 @@ namespace kiwano
|
|||
// 获取图形展开成一条直线的长度
|
||||
float GetLength();
|
||||
|
||||
// 셕炬暠近쨌쓺<ECA88C>듐돨貫零뵨학窟蕨좆
|
||||
bool ComputePointAt(
|
||||
float length,
|
||||
Point* point,
|
||||
Point* tangent
|
||||
);
|
||||
|
||||
// 计算面积
|
||||
float ComputeArea();
|
||||
|
||||
// 计算图形路径上点的位置和切线向量
|
||||
bool ComputePointAtLength(
|
||||
float length,
|
||||
Point& point,
|
||||
Vec2& tangent
|
||||
);
|
||||
|
||||
// 设置填充颜色
|
||||
void SetFillColor(
|
||||
const Color& color
|
||||
);
|
||||
|
||||
// 设置线条颜色
|
||||
void SetStrokeColor(
|
||||
const Color& color
|
||||
);
|
||||
|
||||
// 设置线条宽度
|
||||
void SetStrokeWidth(
|
||||
float width
|
||||
);
|
||||
|
||||
// 设置线条相交样式
|
||||
void SetOutlineJoinStyle(
|
||||
StrokeStyle outline_join
|
||||
);
|
||||
|
||||
// 设置形状
|
||||
inline void SetGeometry(ComPtr<ID2D1Geometry> geometry) { geo_ = geometry; }
|
||||
|
||||
// 获取形状
|
||||
inline ComPtr<ID2D1Geometry> GetGeometry() const { return geo_; }
|
||||
|
||||
void OnRender() override;
|
||||
|
||||
protected:
|
||||
ComPtr<ID2D1Geometry> geo_;
|
||||
Color fill_color_;
|
||||
Color stroke_color_;
|
||||
float stroke_width_;
|
||||
StrokeStyle outline_join_;
|
||||
ComPtr<ID2D1Geometry> geo_;
|
||||
};
|
||||
|
||||
|
||||
// 直线
|
||||
class KGE_API LineGeometry
|
||||
: public Geometry
|
||||
class KGE_API LineNode
|
||||
: public ShapeNode
|
||||
{
|
||||
public:
|
||||
LineGeometry();
|
||||
LineNode();
|
||||
|
||||
LineGeometry(
|
||||
LineNode(
|
||||
Point const& begin,
|
||||
Point const& end
|
||||
);
|
||||
|
||||
virtual ~LineGeometry();
|
||||
virtual ~LineNode();
|
||||
|
||||
Point const& GetBegin() const { return begin_; }
|
||||
|
||||
|
|
@ -99,23 +144,23 @@ namespace kiwano
|
|||
};
|
||||
|
||||
|
||||
// 섯부앤近
|
||||
class KGE_API RectangleGeometry
|
||||
: public Geometry
|
||||
// 矩形节点
|
||||
class KGE_API RectNode
|
||||
: public ShapeNode
|
||||
{
|
||||
public:
|
||||
RectangleGeometry();
|
||||
RectNode();
|
||||
|
||||
RectangleGeometry(
|
||||
RectNode(
|
||||
Rect const& rect
|
||||
);
|
||||
|
||||
RectangleGeometry(
|
||||
RectNode(
|
||||
Point const& left_top,
|
||||
Size const& size
|
||||
);
|
||||
|
||||
virtual ~RectangleGeometry();
|
||||
virtual ~RectNode();
|
||||
|
||||
Rect const& GetRect() const { return rect_; }
|
||||
|
||||
|
|
@ -126,19 +171,62 @@ namespace kiwano
|
|||
};
|
||||
|
||||
|
||||
// 섯부途近
|
||||
class KGE_API CircleGeometry
|
||||
: public Geometry
|
||||
// 圆角矩形节点
|
||||
class KGE_API RoundedRectNode
|
||||
: public ShapeNode
|
||||
{
|
||||
public:
|
||||
CircleGeometry();
|
||||
RoundedRectNode();
|
||||
|
||||
CircleGeometry(
|
||||
RoundedRectNode(
|
||||
Rect const& rect,
|
||||
float radius_x,
|
||||
float radius_y
|
||||
);
|
||||
|
||||
virtual ~RoundedRectNode();
|
||||
|
||||
float GetRadiusX() const { return radius_x_; }
|
||||
|
||||
float GetRadiusY() const { return radius_y_; }
|
||||
|
||||
void SetRadius(
|
||||
float radius_x,
|
||||
float radius_y
|
||||
);
|
||||
|
||||
Rect const& GetRect() const { return rect_; }
|
||||
|
||||
void SetRect(
|
||||
Rect const& rect
|
||||
);
|
||||
|
||||
void SetRoundedRect(
|
||||
Rect const& rect,
|
||||
float radius_x,
|
||||
float radius_y
|
||||
);
|
||||
|
||||
protected:
|
||||
Rect rect_;
|
||||
float radius_x_;
|
||||
float radius_y_;
|
||||
};
|
||||
|
||||
|
||||
// 圆形节点
|
||||
class KGE_API CircleNode
|
||||
: public ShapeNode
|
||||
{
|
||||
public:
|
||||
CircleNode();
|
||||
|
||||
CircleNode(
|
||||
Point const& center,
|
||||
float radius
|
||||
);
|
||||
|
||||
virtual ~CircleGeometry();
|
||||
virtual ~CircleNode();
|
||||
|
||||
float GetRadius() const { return radius_; }
|
||||
|
||||
|
|
@ -163,20 +251,20 @@ namespace kiwano
|
|||
};
|
||||
|
||||
|
||||
// 섯부哭途
|
||||
class KGE_API EllipseGeometry
|
||||
: public Geometry
|
||||
// 椭圆节点
|
||||
class KGE_API EllipseNode
|
||||
: public ShapeNode
|
||||
{
|
||||
public:
|
||||
EllipseGeometry();
|
||||
EllipseNode();
|
||||
|
||||
EllipseGeometry(
|
||||
EllipseNode(
|
||||
Point const& center,
|
||||
float radius_x,
|
||||
float radius_y
|
||||
);
|
||||
|
||||
virtual ~EllipseGeometry();
|
||||
virtual ~EllipseNode();
|
||||
|
||||
float GetRadiusX() const { return radius_x_; }
|
||||
|
||||
|
|
@ -206,14 +294,14 @@ namespace kiwano
|
|||
};
|
||||
|
||||
|
||||
// 섯부쨌쓺
|
||||
class KGE_API PathGeometry
|
||||
: public Geometry
|
||||
// 路径节点
|
||||
class KGE_API PathNode
|
||||
: public ShapeNode
|
||||
{
|
||||
public:
|
||||
PathGeometry();
|
||||
PathNode();
|
||||
|
||||
virtual ~PathGeometry();
|
||||
virtual ~PathNode();
|
||||
|
||||
// 开始添加路径
|
||||
void BeginPath(
|
||||
|
|
@ -259,46 +347,4 @@ namespace kiwano
|
|||
ComPtr<ID2D1GeometrySink> current_sink_;
|
||||
};
|
||||
|
||||
|
||||
// 섯부途실앤近
|
||||
class KGE_API RoundedRectGeometry
|
||||
: public Geometry
|
||||
{
|
||||
public:
|
||||
RoundedRectGeometry();
|
||||
|
||||
RoundedRectGeometry(
|
||||
Rect const& rect,
|
||||
float radius_x,
|
||||
float radius_y
|
||||
);
|
||||
|
||||
virtual ~RoundedRectGeometry();
|
||||
|
||||
float GetRadiusX() const { return radius_x_; }
|
||||
|
||||
float GetRadiusY() const { return radius_y_; }
|
||||
|
||||
void SetRadius(
|
||||
float radius_x,
|
||||
float radius_y
|
||||
);
|
||||
|
||||
Rect const& GetRect() const { return rect_; }
|
||||
|
||||
void SetRect(
|
||||
Rect const& rect
|
||||
);
|
||||
|
||||
void SetRoundedRect(
|
||||
Rect const& rect,
|
||||
float radius_x,
|
||||
float radius_y
|
||||
);
|
||||
|
||||
protected:
|
||||
Rect rect_;
|
||||
float radius_x_;
|
||||
float radius_y_;
|
||||
};
|
||||
}
|
||||
|
|
@ -38,14 +38,6 @@ namespace kiwano
|
|||
KGE_DECLARE_SMART_PTR(GifImage);
|
||||
KGE_DECLARE_SMART_PTR(Frames);
|
||||
|
||||
KGE_DECLARE_SMART_PTR(Geometry);
|
||||
KGE_DECLARE_SMART_PTR(LineGeometry);
|
||||
KGE_DECLARE_SMART_PTR(RectangleGeometry);
|
||||
KGE_DECLARE_SMART_PTR(RoundedRectGeometry);
|
||||
KGE_DECLARE_SMART_PTR(CircleGeometry);
|
||||
KGE_DECLARE_SMART_PTR(EllipseGeometry);
|
||||
KGE_DECLARE_SMART_PTR(PathGeometry);
|
||||
|
||||
KGE_DECLARE_SMART_PTR(Node);
|
||||
KGE_DECLARE_SMART_PTR(Scene);
|
||||
KGE_DECLARE_SMART_PTR(Layer);
|
||||
|
|
@ -53,7 +45,13 @@ namespace kiwano
|
|||
KGE_DECLARE_SMART_PTR(GifSprite);
|
||||
KGE_DECLARE_SMART_PTR(Text);
|
||||
KGE_DECLARE_SMART_PTR(Canvas);
|
||||
KGE_DECLARE_SMART_PTR(GeometryNode);
|
||||
KGE_DECLARE_SMART_PTR(ShapeNode);
|
||||
KGE_DECLARE_SMART_PTR(LineNode);
|
||||
KGE_DECLARE_SMART_PTR(RectNode);
|
||||
KGE_DECLARE_SMART_PTR(RoundedRectNode);
|
||||
KGE_DECLARE_SMART_PTR(CircleNode);
|
||||
KGE_DECLARE_SMART_PTR(EllipseNode);
|
||||
KGE_DECLARE_SMART_PTR(PathNode);
|
||||
|
||||
KGE_DECLARE_SMART_PTR(Action);
|
||||
KGE_DECLARE_SMART_PTR(ActionTween);
|
||||
|
|
|
|||
|
|
@ -85,7 +85,6 @@
|
|||
#include "2d/Image.h"
|
||||
#include "2d/GifImage.h"
|
||||
#include "2d/Frames.h"
|
||||
#include "2d/Geometry.h"
|
||||
#include "2d/Action.h"
|
||||
#include "2d/ActionGroup.h"
|
||||
#include "2d/ActionTween.h"
|
||||
|
|
@ -101,7 +100,7 @@
|
|||
#include "2d/GifSprite.h"
|
||||
#include "2d/Text.h"
|
||||
#include "2d/Canvas.h"
|
||||
#include "2d/GeometryNode.h"
|
||||
#include "2d/ShapeNode.h"
|
||||
#include "2d/DebugNode.h"
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -38,36 +38,110 @@ namespace kiwano
|
|||
}
|
||||
}
|
||||
|
||||
inline D2D1_POINT_2F const& ConvertToPoint2F(Vec2 const& point)
|
||||
//
|
||||
// Point2F
|
||||
//
|
||||
|
||||
inline D2D1_POINT_2F const& ConvertToPoint2F(Vec2 const& vec2)
|
||||
{
|
||||
return reinterpret_cast<D2D1_POINT_2F const&>(point);
|
||||
return reinterpret_cast<D2D1_POINT_2F const&>(vec2);
|
||||
}
|
||||
|
||||
inline D2D1_SIZE_F const& ConvertToSizeF(Vec2 const& size)
|
||||
inline D2D1_POINT_2F& ConvertToPoint2F(Vec2& vec2)
|
||||
{
|
||||
return reinterpret_cast<D2D1_SIZE_F const&>(size);
|
||||
return reinterpret_cast<D2D1_POINT_2F&>(vec2);
|
||||
}
|
||||
|
||||
inline const D2D1_POINT_2F* ConvertToPoint2F(const Vec2* vec2)
|
||||
{
|
||||
return reinterpret_cast<const D2D1_POINT_2F*>(vec2);
|
||||
}
|
||||
|
||||
inline D2D1_POINT_2F* ConvertToPoint2F(Vec2* vec2)
|
||||
{
|
||||
return reinterpret_cast<D2D1_POINT_2F*>(vec2);
|
||||
}
|
||||
|
||||
//
|
||||
// SizeF
|
||||
//
|
||||
|
||||
inline D2D1_SIZE_F const& ConvertToSizeF(Vec2 const& vec2)
|
||||
{
|
||||
return reinterpret_cast<D2D1_SIZE_F const&>(vec2);
|
||||
}
|
||||
|
||||
inline D2D1_SIZE_F& ConvertToSizeF(Vec2& vec2)
|
||||
{
|
||||
return reinterpret_cast<D2D1_SIZE_F&>(vec2);
|
||||
}
|
||||
|
||||
inline const D2D1_SIZE_F* ConvertToSizeF(const Vec2* vec2)
|
||||
{
|
||||
return reinterpret_cast<const D2D1_SIZE_F*>(vec2);
|
||||
}
|
||||
|
||||
inline D2D1_SIZE_F* ConvertToSizeF(Vec2* vec2)
|
||||
{
|
||||
return reinterpret_cast<D2D1_SIZE_F*>(vec2);
|
||||
}
|
||||
|
||||
//
|
||||
// SizeF
|
||||
//
|
||||
|
||||
inline D2D1_RECT_F ConvertToRectF(Rect const& rect)
|
||||
{
|
||||
return D2D1_RECT_F{ rect.origin.x, rect.origin.y, rect.origin.x + rect.size.x, rect.origin.y + rect.size.y };
|
||||
}
|
||||
|
||||
//
|
||||
// SizeF
|
||||
//
|
||||
inline D2D1_COLOR_F const& ConvertToColorF(Color const& color)
|
||||
{
|
||||
return reinterpret_cast<D2D1_COLOR_F const&>(color);
|
||||
}
|
||||
|
||||
inline D2D1_COLOR_F& ConvertToColorF(Color& color)
|
||||
{
|
||||
return reinterpret_cast<D2D1_COLOR_F&>(color);
|
||||
}
|
||||
|
||||
inline const D2D1_COLOR_F* ConvertToColorF(const Color* color)
|
||||
{
|
||||
return reinterpret_cast<const D2D1_COLOR_F*>(color);
|
||||
}
|
||||
|
||||
inline D2D1_COLOR_F* ConvertToColorF(Color* color)
|
||||
{
|
||||
return reinterpret_cast<D2D1_COLOR_F*>(color);
|
||||
}
|
||||
|
||||
//
|
||||
// SizeF
|
||||
//
|
||||
|
||||
inline D2D1_MATRIX_3X2_F const& ConvertToMatrix3x2F(Matrix const& matrix)
|
||||
{
|
||||
return reinterpret_cast<D2D1_MATRIX_3X2_F const&>(matrix);
|
||||
}
|
||||
|
||||
inline D2D1_MATRIX_3X2_F& ConvertToMatrix3x2F(Matrix& matrix)
|
||||
{
|
||||
return reinterpret_cast<D2D1_MATRIX_3X2_F&>(matrix);
|
||||
}
|
||||
|
||||
inline const D2D1_MATRIX_3X2_F* ConvertToMatrix3x2F(const Matrix* matrix)
|
||||
{
|
||||
return reinterpret_cast<const D2D1_MATRIX_3X2_F*>(matrix);
|
||||
}
|
||||
|
||||
inline D2D1_MATRIX_3X2_F* ConvertToMatrix3x2F(Matrix* matrix)
|
||||
{
|
||||
return reinterpret_cast<D2D1_MATRIX_3X2_F*>(matrix);
|
||||
}
|
||||
|
||||
// Converts a length in device-independent pixels (DIPs) to a length in physical pixels.
|
||||
inline float ConvertDipsToPixels(float dips, float dpi)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -179,7 +179,10 @@ namespace kiwano
|
|||
device_context_->SaveDrawingState(drawing_state_block_.Get());
|
||||
|
||||
device_context_->BeginDraw();
|
||||
return S_OK;
|
||||
|
||||
HRESULT hr = d3d_res_->ClearRenderTarget(clear_color_);
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
HRESULT Renderer::EndDraw()
|
||||
|
|
@ -196,11 +199,6 @@ namespace kiwano
|
|||
hr = d3d_res_->Present(vsync_);
|
||||
}
|
||||
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
hr = d3d_res_->ClearRenderTarget(clear_color_);
|
||||
}
|
||||
|
||||
if (hr == DXGI_ERROR_DEVICE_REMOVED || hr == DXGI_ERROR_DEVICE_RESET)
|
||||
{
|
||||
// 如果 Direct3D 设备在执行过程中消失,将丢弃当前的设备相关资源
|
||||
|
|
|
|||