mirror of
https://github.com/geode-sdk/geode.git
synced 2024-11-23 07:57:51 -05:00
add util geode::cocos::getMousePos
This commit is contained in:
parent
5f3c6587b3
commit
306fde70d0
2 changed files with 20 additions and 13 deletions
|
@ -682,19 +682,12 @@ namespace geode::cocos {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
// template<typename K, typename V,
|
/**
|
||||||
// typename = std::enable_if_t<std::is_same_v<K, std::string> || std::is_same_v<K, intptr_t>> >
|
* Gets the mouse position in cocos2d coordinates.
|
||||||
// static std::map<K, V> ccDictToMap(cocos2d::CCDictionary* dict) {
|
* On mobile platforms this will probably return (0, 0)
|
||||||
// auto res = std::map<K, V>();
|
* @returns The mouse position
|
||||||
// cocos2d::CCDictElement* element = nullptr;
|
*/
|
||||||
// CCDICT_FOREACH(dict, element) {
|
GEODE_DLL cocos2d::CCPoint getMousePos();
|
||||||
// if constexpr (std::is_same_v<K, std::string>)
|
|
||||||
// res[element->getStrKey()] = element->getObject();
|
|
||||||
// if constexpr (std::is_same_v<K, intptr_t>)
|
|
||||||
// res[element->getIntKey()] = element->getObject();
|
|
||||||
// }
|
|
||||||
// return res;
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// std specializations
|
// std specializations
|
||||||
|
|
|
@ -330,6 +330,20 @@ CCScene* geode::cocos::switchToScene(CCLayer* layer) {
|
||||||
return scene;
|
return scene;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CCPoint geode::cocos::getMousePos() {
|
||||||
|
#ifdef GEODE_IS_WINDOWS
|
||||||
|
auto* director = CCDirector::get();
|
||||||
|
auto* gl = director->getOpenGLView();
|
||||||
|
auto winSize = director->getWinSize();
|
||||||
|
auto frameSize = gl->getFrameSize();
|
||||||
|
auto mouse = gl->getMousePosition() / frameSize;
|
||||||
|
return ccp(mouse.x, 1.f - mouse.y) * winSize;
|
||||||
|
#else
|
||||||
|
// TODO: implement this for mac
|
||||||
|
return ccp(0, 0);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
static CreateLayerFunc LOADING_FINISHED_SCENE = nullptr;
|
static CreateLayerFunc LOADING_FINISHED_SCENE = nullptr;
|
||||||
|
|
||||||
void geode::cocos::reloadTextures(CreateLayerFunc returnTo) {
|
void geode::cocos::reloadTextures(CreateLayerFunc returnTo) {
|
||||||
|
|
Loading…
Reference in a new issue