本文整理汇总了C++中Director::getWinSize方法的典型用法代码示例。如果您正苦于以下问题:C++ Director::getWinSize方法的具体用法?C++ Director::getWinSize怎么用?C++ Director::getWinSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Director
的用法示例。
在下文中一共展示了Director::getWinSize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DoInitFixedScreenSize
void ScreenSizeManager::DoInitFixedScreenSize(float myScreenWidth,
float myScreenHeight)
{
_isInit = true;
// cocos2d-x v3.0.0 이상만 지원.
CCAssert(0x00030000 <= COCOS2D_VERSION, "ScreenSizeManager need to cocos2d-x 3.0.0 or higher!");
Director* kDirector = CCDirector::getInstance();
CCAssert(kDirector->getOpenGLView(), "ScreenSizeManager need to kDirector->getOpenGLView() is not NULL");
Size kWinSize = kDirector->getWinSize();
_screenSize.width = kWinSize.width;
_screenSize.height = kWinSize.height;
_imageResolutionSize.width = myScreenWidth;
_imageResolutionSize.height = myScreenHeight;
log("DoInitFixedScreenSizeManager %f %f", _imageResolutionSize.width, _imageResolutionSize.height);
// Cocos2d상의 포인트영역이 _imageResolutionSize.width, _imageResolutionSize.height 으로 설정된다.
// CCDirector::sharedDirector()->getWinSize()의 width, height 가 _imageResolutionSize.width, _imageResolutionSize.height 로 된다.
ResolutionPolicy kResolutionPolicy = ResolutionPolicy::NO_BORDER;
GLView* kGLView = kDirector->getOpenGLView();
kGLView->setDesignResolutionSize(_imageResolutionSize.width, _imageResolutionSize.height, kResolutionPolicy);
}
示例2: initWithPhysics
bool Scene::initWithPhysics()
{
#if CC_USE_PHYSICS
_physicsWorld = PhysicsWorld::construct(this);
#endif
bool ret = false;
do
{
Director * director;
CC_BREAK_IF( ! (director = Director::getInstance()) );
this->setContentSize(director->getWinSize());
#if CC_USE_3D_PHYSICS && CC_ENABLE_BULLET_INTEGRATION
Physics3DWorldDes info;
CC_BREAK_IF(! (_physics3DWorld = Physics3DWorld::create(&info)));
_physics3DWorld->retain();
#endif
// success
ret = true;
} while (0);
return ret;
}
示例3: applicationDidFinishLaunching
bool AppDelegate::applicationDidFinishLaunching() {
// initialize director
Director* director = Director::getInstance();
EGLView* glView = EGLView::getInstance();
director->setOpenGLView(glView);
Size size = director->getWinSize();
setDesignResolution();
// Set the design resolution
glView->setDesignResolutionSize(designResolutionSize.width, designResolutionSize.height, ResolutionPolicy::NO_BORDER);
// turn on display FPS
//director->setDisplayStats(true);
// set FPS. the default value is 1.0/60 if you don't call this
director->setAnimationInterval(1.0 / 60);
// create a scene. it's an autorelease object
#if(CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
Scene *scene = MainTitleScene::create();
#else
Scene *scene = HelloWorld::scene();
#endif
// run
director->runWithScene(scene);
return true;
}
示例4: _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);
}
示例5: getFullScreenSize
Size Screen::getFullScreenSize(float scale) {
if (0.0f == scale) {
return Size::ZERO;
}
Director* director = Director::getInstance();
Size windowSize = director->getWinSize();
windowSize.width *= scale;
windowSize.height *= scale;
return windowSize;
}
示例6: init
bool Layer::init()
{
bool ret = false;
do
{
Director * director;
CC_BREAK_IF(!(director = Director::getInstance()));
this->setContentSize(director->getWinSize());
// success
ret = true;
} while(0);
return ret;
}
示例7: DoInitFlexibleScreenSize
void ScreenSizeManager::DoInitFlexibleScreenSize(float myImageResolutionWidth,
float myImageResolutionHeight)
{
_isInit = true;
// cocos2d-x v3.0.0 이상만 지원.
CCAssert(0x00030000 <= COCOS2D_VERSION, "ScreenSizeManager need to cocos2d-x 3.0.0 or higher!");
Director* kDirector = Director::getInstance();
CCAssert(kDirector->getOpenGLView(), "ScreenSizeManager need to kDirector->getOpenGLView() is not NULL");
Size kWinSize = kDirector->getWinSize();
_screenSize.width = kWinSize.width;
_screenSize.height = kWinSize.height;
_imageResolutionSize.width = myImageResolutionWidth;
_imageResolutionSize.height = myImageResolutionHeight;
float kDefaultDesignResRatio = _imageResolutionSize.width / _imageResolutionSize.height;
float kScreenRatio = _screenSize.width / _screenSize.height;
if ( kDefaultDesignResRatio <= kScreenRatio)
{
float kHeightRatio = _screenSize.height / _imageResolutionSize.height;
// 폭이 넓은 경우
_imageResolutionSize.width = (int)(_screenSize.width / kHeightRatio);
_isScaleHeight = true;
}
else
{
// 높이가 긴 경우
float kWidthRatio = _screenSize.width / _imageResolutionSize.width;
// 폭이 넓은 경우
_imageResolutionSize.height = (int)(_screenSize.height / kWidthRatio);
_isScaleHeight = false;
}
log("DoInitResourceSizeScreen %f %f", _imageResolutionSize.width, _imageResolutionSize.height);
// Cocos2d상의 포인트영역이 _imageResolutionSize.width, _imageResolutionSize.height 으로 설정된다.
// CCDirector::sharedDirector()->getWinSize()의 width, height 가 _imageResolutionSize.width, _imageResolutionSize.height 로 된다.
ResolutionPolicy kResolutionPolicy = ResolutionPolicy::NO_BORDER;
GLView* kGLView = kDirector->getOpenGLView();
kGLView->setDesignResolutionSize(_imageResolutionSize.width, _imageResolutionSize.height, kResolutionPolicy);
}
示例8: init
bool Layer::init()
{
bool bRet = false;
do
{
Director * pDirector;
CC_BREAK_IF(!(pDirector = Director::getInstance()));
this->setContentSize(pDirector->getWinSize());
setTouchEnabled(false);
setAccelerometerEnabled(false);
// success
bRet = true;
} while(0);
return bRet;
}
示例9: init
bool MapScene::init()
{
if (!Scene::init()){
return false;
}
Director *director = Director::getInstance();
Size winSize = director->getWinSize();
Layer *mapLayer = Layer::create();
Sprite *map = Sprite::create("Map/Main_Main.png");
map->setAnchorPoint(Vec2::ZERO);
mapLayer->addChild(map);
Sprite *regionNormal = Sprite::create("Map/Main_flag.png");
Sprite *regionSelected = Sprite::create("Map/Main_flag.png");
regionSelected->setScale(1.2f);
std::function<void(Ref *ref)>
onRegionTouched = [this](Ref *ref)->void
{
if (_readyMenu) {
delete _readyMenu;
_readyMenu = nullptr;
}
RegionInfo regionInfo;
HeroInfo heroInfo;
regionInfo.stageName = "Stage1.json";
heroInfo.heroName = "normal";
_readyMenu = new ReadyMenu(regionInfo, heroInfo);
Layer *readyLayer = _readyMenu->getLayer();
addChild(readyLayer);
};
MenuItemSprite *regionMenuItem = MenuItemSprite::create(regionNormal, regionSelected, onRegionTouched);
Menu *regionMenu = Menu::create(regionMenuItem, nullptr);
regionMenu->setPosition(Vec2(700.0f, 220.0f));
mapLayer->addChild(regionMenu);
ScrollView *scrollView = ScrollView::create(winSize, mapLayer);
scrollView->setTouchEnabled(true);
scrollView->setContentSize(map->getContentSize());
scrollView->setPosition(Vec2::ZERO);
scrollView->setDirection(ScrollView::Direction::BOTH);
scrollView->setBounceable(false);
addChild(scrollView);
return true;
}
示例10: initWithPhysics
bool Scene::initWithPhysics()
{
bool ret = false;
do
{
Director * director;
CC_BREAK_IF( ! (director = Director::getInstance()) );
this->setContentSize(director->getWinSize());
CC_BREAK_IF(! (_physicsWorld = PhysicsWorld::construct(*this)));
// success
ret = true;
} while (0);
return ret;
}
示例11: 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());
}
}
示例12: init
// on "init" you need to initialize your instance
bool LogoLayer::init()
{
if ( !Layer::init() )
{
return false;
}
Sprite* logo = Sprite::create("logo.png");
Director* director = Director::getInstance();
Size winSize = director->getWinSize();
logo->setPosition(Point(winSize.width * 0.5, winSize.height * 0.5));
addChild(logo);
EventListenerTouchOneByOne* listener = EventListenerTouchOneByOne::create();
listener->onTouchBegan = CC_CALLBACK_2(LogoLayer::onTouchBegan, this);
_eventDispatcher->addEventListenerWithSceneGraphPriority(listener, logo);
return true;
}
示例13: initWithPhysics
bool PhysicsNode::initWithPhysics()
{
bool ret = false;
// ret = Scene::initWithPhysics();
do
{
Director * director;
CC_BREAK_IF( ! (director = Director::getInstance()) );
this->setContentSize(director->getWinSize());
CC_BREAK_IF(! (_physicsWorld = spritebuilder::CCBPhysicsWorld::construct(*this)));
this->scheduleUpdate();
// success
ret = true;
} while (0);
return ret;
this->setContentSize(Size(0, 0));
//this->getPhysicsWorld()->setDebugDrawMask(PhysicsWorld::DEBUGDRAW_ALL);
return ret;
}
示例14: init
bool Layer::init()
{
Director * director = Director::getInstance();
setContentSize(director->getWinSize());
return true;
}
示例15: getEdgePosition
Position Screen::getEdgePosition(int zorder) {
Director* director = Director::getInstance();
Size windowSize = director->getWinSize();
return Position(Vec2(windowSize.width, windowSize.height), zorder);
}