本文整理汇总了C++中GLView::getFrameSize方法的典型用法代码示例。如果您正苦于以下问题:C++ GLView::getFrameSize方法的具体用法?C++ GLView::getFrameSize怎么用?C++ GLView::getFrameSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GLView
的用法示例。
在下文中一共展示了GLView::getFrameSize方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _startGameMenuCallback
void WelcomeMenu::_startGameMenuCallback(Ref* pSender)
{
Director* director = Director::getInstance();
GLView* glView = director->getOpenGLView();
Size frameSize = glView->getFrameSize();
Size winSize = director->getWinSize();
log("winSize %f=%f ",winSize.width, winSize.height );
log("frameSize %f=%f", frameSize.width, frameSize.height);
}
示例2: draw
void WebViewImpl::draw(Renderer *renderer, Mat4 const &transform, uint32_t flags)
{
if (_createSucceeded && (flags & Node::FLAGS_TRANSFORM_DIRTY))
{
Director *directorInstance = cocos2d::Director::getInstance();
GLView *glView = directorInstance->getOpenGLView();
const Size &frameSize = glView->getFrameSize();
const Size &winSize = directorInstance->getWinSize();
Vec2 leftBottom = this->_webView->convertToWorldSpace(Point::ZERO);
Vec2 rightTop = this->_webView->convertToWorldSpace(Point(_webView->getContentSize().width, _webView->getContentSize().height));
float uiLeft = frameSize.width / 2 + (leftBottom.x - winSize.width / 2) * glView->getScaleX();
float uiTop = frameSize.height / 2 - (rightTop.y - winSize.height / 2) * glView->getScaleY();
_systemWebControl->setWebViewRect(uiLeft, uiTop,
(rightTop.x - leftBottom.x) * glView->getScaleX(),
(rightTop.y - leftBottom.y) * glView->getScaleY());
}
}
示例3: setBackground
void PopupLayer::setBackground()
{
GLView* pEGLView = Director::getInstance()->getOpenGLView();
Size frameSize = pEGLView->getFrameSize();
Sprite *colorBG = Sprite::create();
colorBG->setTextureRect(Rect(0, 0, frameSize.width, frameSize.height));
colorBG->setColor(Color3B::BLACK);
colorBG->setOpacity(150);
colorBG->setPosition(Point(0, 0));
colorBG->setScale(2.0f);
this->addChild(colorBG);
if (mBackgroundImage.size() > 0) {
mBackgroundSprite = Sprite::create(mBackgroundImage.c_str());
this->addChild(mBackgroundSprite);
}
else {
mBackgroundSprite = Sprite::create();
this->addChild(mBackgroundSprite);
}
}
示例4: init
bool ScreenTest::init()
{
// 物理分辨率
GLView *glview = Director::getInstance()->getOpenGLView();
Size frameSize = glview->getFrameSize();
CCLOG("FRAME SIZE: %dx%d", (int)frameSize.width, (int)frameSize.height);
// Result:
// iPhone(3.5-inch) 960x640 1.5
// iPhone(4-inch) 1136x640 1.775
// iPad 1024x768 1.333
// iPad Retina 2048x1536 1.333
// 设置逻辑上的游戏屏幕大小
// ResolutionPolicy::EXACT_FIT为了保持了全屏显示,对画面进行了拉伸(不推荐!)
// glview->setDesignResolutionSize(400, 480, ResolutionPolicy::EXACT_FIT);
// ResolutionPolicy::SHOW_ALL为了保持设计画面比例对四周进行留黑边处理,使得不同比例下画面不能全屏。
// glview->setDesignResolutionSize(400, 480, ResolutionPolicy::SHOW_ALL);
// ResolutionPolicy::NO_BORDER为了填补留下的黑边,将画面稍微放大,以至于能够正好补齐黑边
glview->setDesignResolutionSize(m_designWidth, m_designHeight, ResolutionPolicy::NO_BORDER);
// 其他参数,参考ResolutionPolicy的注释
Size winSize = Director::getInstance()->getWinSize();
CCLOG("WIN SIZE: %dx%d", (int)winSize.width, (int)winSize.height);
// Result: winSize的大小为glview->setDesignResolutionSize()设置的值
// 默认为FrameSize
auto dispatcher = Director::getInstance()->getEventDispatcher();
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
// Add Touch Listener
auto touchListener = EventListenerTouchAllAtOnce::create();
touchListener->onTouchesBegan = CC_CALLBACK_2(ScreenTest::onTouchesBegan, this);
touchListener->onTouchesMoved = CC_CALLBACK_2(ScreenTest::onTouchesMoved, this);
touchListener->onTouchesEnded = CC_CALLBACK_2(ScreenTest::onTouchesEnded, this);
touchListener->onTouchesCancelled = CC_CALLBACK_2(ScreenTest::onTouchesCancelled, this);
dispatcher->addEventListenerWithSceneGraphPriority(touchListener, this);
#elif (CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
// Add Mouse Listener
auto mouseListener = EventListenerMouse::create();
// mouseListener->onMouseMove = CC_CALLBACK_1(ScreenTest::onMouseMove, this);
// mouseListener->onMouseUp = CC_CALLBACK_1(ScreenTest::onMouseUp, this);
// mouseListener->onMouseDown = CC_CALLBACK_1(ScreenTest::onMouseDown, this);
mouseListener->onMouseScroll = CC_CALLBACK_1(ScreenTest::onMouseScroll, this);
dispatcher->addEventListenerWithSceneGraphPriority(mouseListener, this);
#endif
m_editWidth = UIUtil::createEditBox(this, 100, 160, "Design Width");
m_editHeight = UIUtil::createEditBox(this, 100, 100, "Design Height");
m_editHeight->setInputMode(EditBox::InputMode::NUMERIC);
m_editWidth->setInputMode(EditBox::InputMode::NUMERIC);
char width[32];
sprintf(width, "%d", (int)winSize.width);
m_editWidth->setText(width);
char height[32];
sprintf(height, "%d", (int)winSize.height);
m_editHeight->setText(height);
return true;
}
示例5: openKeyboard
void EditBoxImplTizen::openKeyboard()
{
if (s_keypadWin)
{
return;
}
if (_delegate != NULL)
{
_delegate->editBoxEditingDidBegin(_editBox);
}
#if CC_ENABLE_SCRIPT_BINDING
EditBox* pEditBox = this->getEditBox();
if (NULL != pEditBox && 0 != pEditBox->getScriptEditBoxHandler())
{
CommonScriptData data(pEditBox->getScriptEditBoxHandler(), "began",pEditBox);
ScriptEvent event(cocos2d::kCommonEvent,(void*)&data);
ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event);
}
#endif
Evas_Object* parent = Application::getInstance()->_win;
GLView* glView = Director::getInstance()->getOpenGLView();
Size frameSize = glView->getFrameSize();
s_keypadWin = elm_win_add(parent, "cocos2d-x", ELM_WIN_BASIC);
elm_win_autodel_set(s_keypadWin, EINA_TRUE);
elm_win_conformant_set(s_keypadWin, EINA_TRUE);
elm_win_alpha_set(s_keypadWin, EINA_TRUE);
evas_object_show(s_keypadWin);
eext_object_event_callback_add(s_keypadWin, EEXT_CALLBACK_BACK, entry_back_cb, this);
int rots[2];
rots[0] = (int)(elm_win_rotation_get(parent));
rots[1] = rots[0] + 180 % 360;
elm_win_wm_rotation_available_rotations_set(s_keypadWin, rots, 2);
Evas_Object* bgFull = elm_bg_add(s_keypadWin);
evas_object_color_set(bgFull, 0, 0, 0, 0xa0);
evas_object_resize(bgFull, frameSize.width, frameSize.height);
evas_object_show(bgFull);
int height = frameSize.height / 10;
Evas_Object* rectangle = elm_bg_add(bgFull);
evas_object_resize(rectangle, frameSize.width, height);
evas_object_move(rectangle, 0, height);
evas_object_color_set(rectangle, 0xff, 0xff, 0xff, 0xff);
evas_object_show(rectangle);
Evas_Object* title = elm_entry_add(rectangle);
evas_object_resize(title, frameSize.width, height);
auto text = _placeHolder.c_str();
auto richText = (char*)malloc(strlen(text) + 50);
sprintf(richText,"<color=#ffffff>%s</>", text);
elm_entry_entry_set(title, richText);
elm_entry_editable_set(title, EINA_FALSE);
//elm_entry_drag_disabled_set(title, EINA_TRUE);
//elm_entry_drop_disabled_set(title, EINA_TRUE);
evas_object_show(title);
free(richText);
Evas_Object* entry = elm_entry_add(bgFull);
elm_object_focus_set(entry, EINA_TRUE);
evas_object_resize(entry, frameSize.width, height);
evas_object_move(entry, 0, height);
elm_entry_single_line_set(entry, EINA_TRUE);
elm_entry_line_wrap_set(entry, ELM_WRAP_MIXED);
elm_entry_entry_set(entry, _text.c_str());
evas_object_show(entry);
elm_object_focus_set(entry, EINA_TRUE);
eext_entry_selection_back_event_allow_set(entry, EINA_TRUE);
Elm_Entry_Filter_Limit_Size limit_size = { 0, };
limit_size.max_char_count = _maxLength;
elm_entry_markup_filter_append(entry, elm_entry_filter_limit_size, &limit_size);
elm_entry_input_panel_return_key_type_set(entry, ELM_INPUT_PANEL_RETURN_KEY_TYPE_DONE);
elm_entry_prediction_allow_set(entry, EINA_FALSE);
evas_object_smart_callback_add(entry, "activated", entry_activated_cb, this);
switch(_editBoxInputFlag)
{
case EditBox::InputFlag::PASSWORD:
elm_entry_password_set(entry, EINA_TRUE);
elm_entry_input_panel_layout_set(entry, ELM_INPUT_PANEL_LAYOUT_EMAIL);
break;
case EditBox::InputFlag::SENSITIVE:
elm_entry_input_hint_set(entry, ELM_INPUT_HINT_SENSITIVE_DATA);
break;
case EditBox::InputFlag::INITIAL_CAPS_WORD:
elm_entry_autocapital_type_set(entry, ELM_AUTOCAPITAL_TYPE_WORD);
break;
case EditBox::InputFlag::INITIAL_CAPS_SENTENCE:
elm_entry_autocapital_type_set(entry, ELM_AUTOCAPITAL_TYPE_SENTENCE);
break;
case EditBox::InputFlag::INITIAL_CAPS_ALL_CHARACTERS:
elm_entry_autocapital_type_set(entry, ELM_AUTOCAPITAL_TYPE_ALLCHARACTER);
break;
}
switch(_editBoxInputMode)
//.........这里部分代码省略.........
示例6: onGLFWMouseMoveCallBack
void GLViewEventHandler::onGLFWMouseMoveCallBack(GLFWwindow* window, double x, double y)
{
GLView* eglView = Director::getInstance()->getOpenGLView();
if(nullptr == eglView) return;
if (eglView->isRetina()) {
x *= 2;
y *= 2;
}
s_mouseX = (float)x;
s_mouseY = (float)y;
s_mouseX /= eglView->getFrameZoomFactor();
s_mouseY /= eglView->getFrameZoomFactor();
if(s_captured)
{
if (eglView->getViewPortRect().equals(Rect::ZERO) || eglView->getViewPortRect().containsPoint(Point(s_mouseX,eglView->getFrameSize().height - s_mouseY)))
{
int id = 0;
eglView->handleTouchesMove(1, &id, &s_mouseX, &s_mouseY);
}
}
EventMouse event(EventMouse::MouseEventType::MOUSE_MOVE);
//Because OpenGL and cocos2d-x uses different Y axis, we need to convert the coordinate here
event.setCursorPosition(s_mouseX, eglView->getViewPortRect().size.height - s_mouseY);
Director::getInstance()->getEventDispatcher()->dispatchEvent(&event);
}
示例7: applicationDidFinishLaunching
bool AppDelegate::applicationDidFinishLaunching() {
// initialize director
Director* pDirector = gDirector;
GLView* pGLView = pDirector->getOpenGLView();
if( NULL == pGLView )
{
pGLView = GLView::create("game(v1.0.0.0)---test for inner");
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
pGLView->setFrameSize(1334, 750);
#endif
pDirector->setOpenGLView(pGLView);
}
// turn on display FPS
pDirector->setDisplayStats(true);
// set FPS. the default value is 1.0/60 if you don't call this
pDirector->setAnimationInterval(1.0 / 60);
// resolution information
Size size;
size= pDirector->getWinSize();
log("***IDONG: Director getWinSize:w=%f,h=%f",size.width,size.height);
size = pDirector->getWinSizeInPixels();
log("***IDONG: Director getWinSizeInPixels:w=%f,h=%f",size.width,size.height);
size = pDirector->getVisibleSize();
log("***IDONG: Director getVisibleSize:w=%f,h=%f",size.width,size.height);
Point point = pDirector->getVisibleOrigin();
log("***IDONG: Director getVisibleOrigin:x=%f,y=%f",point.x,point.y);
log("***IDONG: Director BS: getContentScaleFactor: scaleFactor=%f",pDirector->getContentScaleFactor());
auto framsize = pGLView->getFrameSize();
auto dwinsize = pDirector->getWinSize();
auto designsize = Size(SCREEN_WIDTH, SCREEN_HEIGHT);
auto widthRate = framsize.width/designsize.width;
auto heightRate = framsize.height/designsize.height;
auto resolutionRate = 1.f;
if(widthRate > heightRate)
{
pGLView->setDesignResolutionSize(designsize.width,
designsize.height*heightRate/widthRate, ResolutionPolicy::NO_BORDER);
resolutionRate = heightRate/widthRate;
}
else
{
pGLView->setDesignResolutionSize(designsize.width*widthRate/heightRate, designsize.height,
ResolutionPolicy::NO_BORDER);
resolutionRate = widthRate/heightRate;
}
//pGLView->setDesignResolutionSize(SCREEN_WIDTH, SCREEN_HEIGHT, ResolutionPolicy::FIXED_HEIGHT);
log("***IDONG:/n");
log("***IDONG: Director AS: getContentScaleFactor: scaleFactor=%f",pDirector->getContentScaleFactor());
size= pDirector->getWinSize();
log("***IDONG: Director getWinSize:w=%f,h=%f",size.width,size.height);
size = pDirector->getWinSizeInPixels();
log("***IDONG: Director getWinSizeInPixels:w=%f,h=%f",size.width,size.height);
size = pDirector->getVisibleSize();
log("***IDONG: Director getVisibleSize:w=%f,h=%f",size.width,size.height);
point = pDirector->getVisibleOrigin();
log("***IDONG: Director getVisibleOrigin:x=%f,y=%f",point.x,point.y);
// ‘ˆº”À—À˜¬∑æ∂
gFileUtils->addSearchPath("assets");
// …Ë÷√◊ ‘¥ƒø¬�?
// ≥ı ºªØ◊ ‘¥ƒø¬�?dumpŒƒº˛…˙≥…ƒø¬�?
string logfile = "";
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
gGameManager->SetResourceRoot("/mnt/sdcard/com.zm.mszb/");
gGameManager->CreateDirectory(gGameManager->GetResourceRoot());
gGameManager->CreateDirectory(gGameManager->GetLogPath());
logfile = gGameManager->GetLogPath()+"/log.txt";
gLog->Open(logfile.c_str());
#endif
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
gGameManager->SetResourceRoot("");
gGameManager->CreateDirectory(gGameManager->GetResourceRoot());
gGameManager->CreateDirectory(gGameManager->GetLogPath());
logfile = gGameManager->GetLogPath()+"/log.txt";
gLog->Open(logfile.c_str());
#endif
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
gGameManager->SetResourceRoot(gFileUtils->getWritablePath());
gGameManager->CreateDirectory(gGameManager->GetResourceRoot());
gGameManager->CreateDirectory(gGameManager->GetLogPath());
logfile = gGameManager->GetLogPath()+"/log.txt";
//.........这里部分代码省略.........