本文整理汇总了C++中THMap::worldToScreen方法的典型用法代码示例。如果您正苦于以下问题:C++ THMap::worldToScreen方法的具体用法?C++ THMap::worldToScreen怎么用?C++ THMap::worldToScreen使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类THMap
的用法示例。
在下文中一共展示了THMap::worldToScreen方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _l_on_ui_scroll_map
int ScrollableGamePanel::_l_on_ui_scroll_map(lua_State *L)
{
ScrollableGamePanel *pThis = reinterpret_cast<ScrollableGamePanel*>(
lua_touserdata(L, lua_upvalueindex(2)));
// Make a copy of the "self" parameter at the bottom of the stack
lua_pushvalue(L, 1);
lua_insert(L, 1);
// Call original GameUI:scrollMap() function
lua_pushvalue(L, lua_upvalueindex(1));
lua_insert(L, 2);
lua_call(L, lua_gettop(L) - 2, LUA_MULTRET);
if(pThis->m_bShouldRespondToScroll)
{
int iPanelW, iPanelH;
pThis->m_pGamePanel->GetSize(&iPanelW, &iPanelH);
// Get world co-ordinates of window center
lua_checkstack(L, 4);
lua_getfield(L, 1, "ScreenToWorld");
lua_pushvalue(L, 1);
lua_pushinteger(L, iPanelW / 2);
lua_pushinteger(L, iPanelH / 2);
lua_call(L, 3, 2);
lua_Number fX = lua_tonumber(L, -2) - 1.0;
lua_Number fY = lua_tonumber(L, -1) - 1.0;
lua_pop(L, 2);
// Get map extents
THMap* pMap = pThis->m_pGamePanel->getMap();
int iMapH = pMap->getHeight();
int iTemp = pMap->getWidth();
pMap->worldToScreen(iTemp, iMapH);
int iMapW = pMap->getWidth();
iTemp = 0;
pMap->worldToScreen(iMapW, iTemp);
// Get screen co-ordinates of window center
// We could get these directly from the GameUI, but we'd be delving into
// its member variables, and also perhaps not properly accounting for zoom.
pMap->worldToScreen(fX, fY);
int iX = (int)fX;
int iY = (int)fY;
// Update scrollbars
pThis->m_pMapScrollX->SetScrollbar(iX + iMapW, iPanelW, iMapW * 2 + iPanelW, iPanelW);
pThis->m_pMapScrollY->SetScrollbar(iY , iPanelH, iMapH + iPanelH, iPanelH);
}
// Return results from original call
return lua_gettop(L) - 1;
}