mirror of
https://github.com/devZoGok/PlanetFleet.git
synced 2026-08-26 19:43:29 +00:00
31 lines
732 B
C++
31 lines
732 B
C++
#include "minimapButton.h"
|
|
#include "activeGameState.h"
|
|
#include "game.h"
|
|
#include "map.h"
|
|
|
|
#include <stateManager.h>
|
|
|
|
#include <node.h>
|
|
#include <mesh.h>
|
|
#include <material.h>
|
|
#include <imageAsset.h>
|
|
#include <assetManager.h>
|
|
|
|
#include <algorithm>
|
|
#include <vector>
|
|
|
|
namespace battleship{
|
|
using namespace vb01;
|
|
using namespace std;
|
|
|
|
void MinimapButton::onClick(){
|
|
Vector2 clickPos = getCursorPos();
|
|
float posXRatio = (clickPos.x - pos.x) / size.x;
|
|
float posYRatio = (clickPos.y - pos.y) / size.y;
|
|
|
|
Camera *cam = Root::getSingleton()->getCamera();
|
|
Vector3 mapSize = Map::getSingleton()->getMapSize();
|
|
cam->setPosition(Vector3(mapSize.x * (-.5 + posXRatio), cam->getPosition().y, mapSize.z * (-.5 + posYRatio)));
|
|
}
|
|
}
|