mirror of
https://github.com/zhenyan121/SporeBG-Conid.git
synced 2026-04-10 06:14:08 +08:00
Add automatic update Button rect function
This commit is contained in:
@@ -11,7 +11,7 @@ GameScene::~GameScene() {
|
||||
void GameScene::onEnter(SDL_Renderer* renderer, int WIDTH, int HEIGHT, UIRenderer* uiRenderer){
|
||||
m_renderer = renderer;
|
||||
m_uiRenderer = uiRenderer;
|
||||
m_gameUIManager = std::make_unique<GameUIManager>();
|
||||
m_gameUIManager = std::make_unique<GameUIManager>(renderer, uiRenderer->getTextRenderer());
|
||||
m_gameUIManager->init();
|
||||
m_gameRenderer = std::make_unique<GameRenderer>(WIDTH, HEIGHT, renderer);
|
||||
m_gameSession = std::make_unique<GameSession>();
|
||||
@@ -49,3 +49,7 @@ void GameScene::handleClick(float screenX, float screenY) {
|
||||
SDL_Log("invail cilck aera!");
|
||||
}
|
||||
}
|
||||
|
||||
void GameScene::renderMousePosition(float x, float y) {
|
||||
m_gameUIManager->UpdateMousePositon(x, y);
|
||||
}
|
||||
@@ -16,6 +16,8 @@ public:
|
||||
void update() override;
|
||||
void render() override;
|
||||
void handleClick(float screenX, float screenY) override;
|
||||
|
||||
void renderMousePosition(float x, float y) override;
|
||||
private:
|
||||
|
||||
std::unique_ptr<GameRenderer> m_gameRenderer;
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
#include "CoordinateTools.h"
|
||||
|
||||
std::pair<int, int> physicalToLogical(const float screenX, const float screenY, SDL_Renderer* renderer) {
|
||||
if (renderer == nullptr) {
|
||||
SDL_Log("Renderer is null in physicalToLogical\n");
|
||||
return {static_cast<int>(screenX), static_cast<int>(screenY)};
|
||||
}
|
||||
|
||||
// 将窗口坐标转为逻辑坐标
|
||||
float logicalX, logicalY;
|
||||
SDL_RenderCoordinatesFromWindow(
|
||||
|
||||
Reference in New Issue
Block a user