Skip to content

v0.3

Choose a tag to compare

@BithreenGirlen BithreenGirlen released this 04 Mar 04:01
· 151 commits to main since this release

Runtime changes

  • Separate resizing window or back-buffer process from spine player.
    • These are now proccessed in main window.
  • Remove Win32API usage in spine player.
    • The size of screen or rendering target are now obtained through DxLib's functions.
  • Enhance efficiency of manipulation in the spine player.
    • Avoid copy where possible.
    • Remove range check inside loop.
  • Acceess skeletonData through drawable instead of directly accessing those which the spine player owns once skeleton is created.

Now dxlib_spine_player can be used with DxLib's built-in window.
Below is simpler (compared to the viewer) code using Spine runtime for DxLib.

Example code
#include "dxlib_init.h"
#include "dxlib_spine_player_c.h"

int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
	_In_opt_ HINSTANCE hPrevInstance,
	_In_ LPWSTR    lpCmdLine,
	_In_ int       nCmdShow)
{
	SDxLibInit sDxLibInit;
	if (sDxLibInit.iDxLibInitialised == -1)return 0;

	const char* szAtlasPath = R"(data\spineboy\export\spineboy.atlas)";
	const char* szSkelPath = R"(data\spineboy\export\spineboy-ess.json)";

	CDxLibSpinePlayerC sSpinePlayer;

	std::vector<std::string> atlasPaths(1, szAtlasPath);
	std::vector<std::string> skelPaths(1, szSkelPath);
	bool bRet = sSpinePlayer.SetSpineFromFile(atlasPaths, skelPaths, false);
	if (!bRet)return 0;

	std::pair<int, int> iDisplaySize;
	DxLib::GetDisplayMaxResolution(&iDisplaySize.first, &iDisplaySize.second);
	DxLib::SetGraphMode(iDisplaySize.first * 10 / 16, iDisplaySize.second * 10 / 16, 32);
	float fDelta = 1 / static_cast<float>(DxLib::GetRefreshRate());

	int keyboardState[256]{};
	std::pair<int, int> iMouseStartPos;
	int iForeMouseState = 0;

	while (DxLib::ProcessMessage() != -1)
	{
		DxLib::GetHitKeyStateAllEx(keyboardState);
		if (keyboardState[KEY_INPUT_ESCAPE] == -1)
		{
			break;
		}
		else if (keyboardState[KEY_INPUT_A] == -1)
		{
			sSpinePlayer.SwitchPma();
		}

		int iCurrentMouseState = DxLib::GetMouseInput();
		if ((iCurrentMouseState & MOUSE_INPUT_LEFT) && !(iForeMouseState & MOUSE_INPUT_LEFT))
		{
			DxLib::GetMousePoint(&iMouseStartPos.first, &iMouseStartPos.second);
		}
		else if (!(iCurrentMouseState & MOUSE_INPUT_LEFT) && (iForeMouseState & MOUSE_INPUT_LEFT))
		{
			std::pair<int, int> iMouseEndPos;
			DxLib::GetMousePoint(&iMouseEndPos.first, &iMouseEndPos.second);

			int iX = iMouseStartPos.first - iMouseEndPos.first;
			int iY = iMouseStartPos.second - iMouseEndPos.second;
			if (iX == 0 && iY == 0)
			{
				sSpinePlayer.ShiftAnimation();
			}
			else
			{
				sSpinePlayer.MoveViewPoint(iX, iY);
			}
		}
		else if (!(iCurrentMouseState & MOUSE_INPUT_MIDDLE) && (iForeMouseState & MOUSE_INPUT_MIDDLE))
		{
			sSpinePlayer.ResetScale();
		}
		iForeMouseState = iCurrentMouseState;

		DxLib::ClearDrawScreen();

		sSpinePlayer.Redraw(fDelta);

		DxLib::ScreenFlip();
	}

	return 0;
}

Viewer changes

  • Prevent window resizing when spine is not yet loaded.
  • Enlarge manipulation dialogue for all the list-views to be equal size.
    • This dialogue can be manually resized once client area is double-clicked.