当前位置: 首页>>代码示例>>C++>>正文


C++ CCDirector::getWinSize方法代码示例

本文整理汇总了C++中CCDirector::getWinSize方法的典型用法代码示例。如果您正苦于以下问题:C++ CCDirector::getWinSize方法的具体用法?C++ CCDirector::getWinSize怎么用?C++ CCDirector::getWinSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CCDirector的用法示例。


在下文中一共展示了CCDirector::getWinSize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: init

bool GameOverScene::init()
{
	bool bRet = false;
    do
    {
        CCDirector * pDirector;
        CC_BREAK_IF( ! (pDirector = CCDirector::sharedDirector()) );
        this->setContentSize(pDirector->getWinSize());
        
        CCSprite* bg = CCSprite::create("gameover.png");
        bg->setPosition(ccp(pDirector->getWinSize().width * 0.5,pDirector->getWinSize().height * 0.5));
        this->addChild(bg);
        
        CCMenuItemFont* mainMenu = CCMenuItemFont::create("Back To Menu",
			this,menu_selector(GameScene::menuPopSceneCallback));
        CCMenuItemFont* close = CCMenuItemFont::create("Exit Game",
			this,menu_selector(GameOverScene::menuCloseCallback));
        CCMenu* menu = CCMenu::create(mainMenu,close,NULL);
        menu->setPosition(ccp(pDirector->getWinSize().width * 0.5,pDirector->getWinSize().height * 0.3));
        menu->alignItemsVertically();
        this->addChild(menu,1);
        // success
        bRet = true;
    } while (0);
    return bRet;
}
开发者ID:253627764,项目名称:CocoStudioSamples,代码行数:26,代码来源:GameScene.cpp

示例2: init

bool ShaderRetroEffect::init()
{
    if( ShaderTestDemo::init() ) {

        GLchar * fragSource = (GLchar*) CCString::createWithContentsOfFile(CCFileUtils::sharedFileUtils()->fullPathFromRelativePath("Shaders/example_HorizontalColor.fsh"))->getCString();
        CCGLProgram *p = new CCGLProgram();
        p->initWithVertexShaderByteArray(ccPositionTexture_vert, fragSource);

        p->addAttribute(kCCAttributeNamePosition, kCCVertexAttrib_Position);
        p->addAttribute(kCCAttributeNameTexCoord, kCCVertexAttrib_TexCoords);

        p->link();
        p->updateUniforms();


        CCDirector *director = CCDirector::sharedDirector();
        CCSize s = director->getWinSize();

        m_pLabel = CCLabelBMFont::create("RETRO EFFECT", "fonts/west_england-64.fnt");

        m_pLabel->setShaderProgram(p);

        p->release();


        m_pLabel->setPosition(ccp(s.width/2,s.height/2));

        addChild(m_pLabel);

        scheduleUpdate();
        return true;
    }

    return false;
}
开发者ID:csdnnet,项目名称:hiygame,代码行数:35,代码来源:ShaderTest.cpp

示例3: doGameEnd

void GameLayer::doGameEnd(CCNode* pSender){
	CCDirector* pDirector = CCDirector::sharedDirector();
	CCSize winSize = pDirector->getWinSize();

	//stop all acitons
	isGameEnded = true;
	heroLayer->unscheduleUpdate();
	heroLayer->unscheduleAllSelectors();
	_enemyAI->unscheduleUpdate();
	_enemyAI->unscheduleAllSelectors();

	//check game win or not
	CCSprite* resultPad = NULL;
	if (my_hero->getLife() <= 0){
		//game lose
		resultPad = CCSprite::create("ui/lose.png");
	}
	else{
		//game win
		resultPad = CCSprite::create("ui/win.png");
		MapLayer* thisMap = MapLayer::getMap();
		thisMap->unlockNextLevel();
		thisMap->setLevelAccomp();
	}
	this->addChild(resultPad, 101);
	resultPad->setPosition(ccp(winSize.width / 2, 
		winSize.height / 2 + resultPad->getContentSize().height / 3));

	//disable touches except back to menu
	CCLayerColor* maskLayer = CCLayerColor::create(ccc4(255, 255, 255, 160), winSize.width, winSize.height);
	this->setZOrder(1);
	this->addChild(maskLayer, 100);
	backIcon->setZOrder(101);
	backIcon->setPosition(ccp(winSize.width / 2, winSize.height / 2 - backIcon->getContentSize().height));
}
开发者ID:houssemeddinelassoued,项目名称:PuppetWars,代码行数:35,代码来源:GameLayer.cpp

示例4: ccTouchesBegan

void GameLayer::ccTouchesBegan(CCSet* pTouch, CCEvent* pEvent){
	
	//check if the backIcon is pressed
	CCTouch *touch = (CCTouch*)pTouch->anyObject();
	CCPoint location = touch->getLocation();
	CCDirector* pDirector = CCDirector::sharedDirector();
	CCSize winSize = pDirector->getWinSize();
	float icon_radius = backIcon->getContentSize().height / 2;
	//distance from icon target to center of the sprite
	float distanceSQ = ccpDistanceSQ(location, backIcon->getPosition());
	if (distanceSQ <= icon_radius * icon_radius){
		//change the icon to pressed
		//MapLayer::getMap()->unlockNextLevel();
		pDirector->popScene();
		return;
	}
	//back button checking ended
	
	
	//gesture detection initiate
	ccp_last = touch->getLocationInView();
	ccp_last = pDirector->convertToGL(ccp_last);

	b_click = true;
	b_rect = false;
	b_circle = false;
	count_order = 0;
	gd_direction = kGDirectionNo;

	for (int i = 0; i < 4; i++){
		cache_deirectionshape[i] = false;
	}
	//gesture detection ended
}
开发者ID:houssemeddinelassoued,项目名称:PuppetWars,代码行数:34,代码来源:GameLayer.cpp

示例5: didAccelerate

void AccelerometerTest::didAccelerate(CCAcceleration* pAccelerationValue)
{
//     double fNow = pAccelerationValue->timestamp;
// 
//     if (m_fLastTime > 0.0)
//     {
//         CCPoint ptNow = convertToUI
//     }
// 
//     m_fLastTime = fNow;

    CCDirector* pDir = CCDirector::sharedDirector();
    CCSize winSize   = pDir->getWinSize();

    /*FIXME: Testing on the Nexus S sometimes m_pBall is NULL */
    if ( m_pBall == NULL ) {
        return;
    }

    CCSize ballSize  = m_pBall->getContentSize();

    CCPoint ptNow  = m_pBall->getPosition();
    CCPoint ptTemp = pDir->convertToUI(ptNow);

    ptTemp.x += pAccelerationValue->x * 9.81f;
    ptTemp.y -= pAccelerationValue->y * 9.81f;

    CCPoint ptNext = pDir->convertToGL(ptTemp);
    FIX_POS(ptNext.x, (ballSize.width / 2.0), (winSize.width - ballSize.width / 2.0));
    FIX_POS(ptNext.y, (ballSize.height / 2.0), (winSize.height - ballSize.height / 2.0));
    m_pBall->setPosition(ptNext);
}
开发者ID:DangoXJ,项目名称:TuJinZhi,代码行数:32,代码来源:AccelerometerTest.cpp

示例6: update

void StartLayer::update(float dt)
{
    CCSprite* title = (CCSprite*)this->getChildByTag(10000);
    CCDirector* pDir = CCDirector::sharedDirector();
    CCSize winSize   = pDir->getWinSize();
    
    //判断小球精灵是否有效。
    if ( title == NULL ) {
        return;
    }
    //取得小球的图像区域大小。
    CCSize ballSize  = title->getContentSize();
    //取得小球的当前位置。
    CCPoint ptNow  = title->getPosition();
    //将当前位置转换成界面坐标系的位置。
    CCPoint ptTemp = pDir->convertToUI(ptNow);
    //由收到的速度乘以一个系数后来影响位置。
    ptTemp.x += posChange.x;
    ptTemp.y -= posChange.y;
    //再转换为OPENGL坐标系的位置。貌似有点麻烦,其实直接在上面X,Y的加减上做上正确的方向即可。
    CCPoint ptNext = pDir->convertToGL(ptTemp);
    //限定位置的X,Y的有效范围,等于小球边缘始终在窗口内。
    FIX_POS(ptNext.x, (ballSize.width / 2.0), (winSize.width - ballSize.width / 2.0));
    FIX_POS(ptNext.y, (ballSize.height / 2.0), (winSize.height - ballSize.height / 2.0));
    //将位置传给小球。
    title->setPosition(ptNext);
    

}
开发者ID:RonberKing,项目名称:IosExample,代码行数:29,代码来源:StartScene.cpp

示例7: buildUI

void PauseLayer::buildUI() {
  this->removeAllChildrenWithCleanup(true);
  _state = PauseLayerStateTop;
  
  this->setTouchEnabled(true);
  
  CCDirector* director = CCDirector::sharedDirector();
  
  CCLayerColor* background = CCLayerColor::create(ccc4(0, 0, 0, 128), director->getWinSize().width, director->getWinSize().height);
  this->addChild(background);
  
  CCSprite* pause = CCSprite::create("pause_label.png");
  pause->setPosition(ccp(director->getWinSize().width / 2.0, 250));
  this->addChild(pause);
  
  _topMenu = CCMenu::create(CCMenuItemImage::create("resume.png", "resume_pressed.png", this, menu_selector(PauseLayer::onCancelPressed)),
                            CCMenuItemImage::create("replay.png", "replay_pressed.png", this, menu_selector(PauseLayer::onReplayPressed)),
                            CCMenuItemImage::create("title.png", "title_pressed.png", this, menu_selector(PauseLayer::onTitlePressed)),
                            NULL);
  
  _confirmMenu = CCMenu::create(CCMenuItemImage::create("yes.png", "yes_pressed.png",
                                                        this, menu_selector(PauseLayer::onYesPressed)),
                                CCMenuItemImage::create("no.png", "no_pressed.png",
                                                        this, menu_selector(PauseLayer::onNoPressed)),
                                NULL);
  _topMenu->setPosition(ccp(director->getWinSize().width / 2.0, 140));
  _confirmMenu->setPosition(ccp(director->getWinSize().width / 2.0, 140));
  _topMenu->alignItemsVerticallyWithPadding(20);
  _topMenu->setAnchorPoint(ccp(0.5, 0.5));
  _confirmMenu->setAnchorPoint(ccp(0.5, 0.5));
  _confirmMenu->alignItemsVerticallyWithPadding(20);
  
  _descriptionLabel = CCLabelTTF::create("ゲームを中断します。よろしいですか?", FONT_NAME, 16);
  _descriptionLabel->setPosition(ccp(director->getWinSize().width / 2.0, 200));
  _descriptionLabel->setVisible(false);
  this->addChild(_descriptionLabel);
  
  _topMenu->retain();
  _confirmMenu->retain();
  _descriptionLabel->retain();
  
  _pausedTargets = new CCSet();
  
  this->addChild(_topMenu);
}
开发者ID:KiRiN,项目名称:VOXCHRONICLE,代码行数:45,代码来源:PauseLayer.cpp

示例8: applicationDidFinishLaunching

bool AppDelegate::applicationDidFinishLaunching()
{
	// As an example, load config file
	// XXX: This should be loaded before the Director is initialized,
	// XXX: but at this point, the director is already initialized
	CCConfiguration::sharedConfiguration()->loadConfigFile("configs/config-example.plist");

    // initialize director
    CCDirector *pDirector = CCDirector::sharedDirector();
    pDirector->setOpenGLView(CCEGLView::sharedOpenGLView());

//    CCSize screenSize = CCEGLView::sharedOpenGLView()->getFrameSize();

    CCSize designSize = CCSizeMake(720, 540);
    
    CCLog("winSize: %f  %f", pDirector->getWinSize().width, pDirector->getWinSize().height );


//    if (screenSize.height > 320)
//    {
//        CCSize resourceSize = CCSizeMake(960, 640);
//        std::vector<std::string> searchPaths;
//        searchPaths.push_back("hd");
//        pFileUtils->setSearchPaths(searchPaths);
//        pDirector->setContentScaleFactor(resourceSize.height/designSize.height);
//    }

    CCEGLView::sharedOpenGLView()->setDesignResolutionSize(designSize.width, designSize.height, kResolutionNoBorder);

//    CCScene * pScene = CCScene::create();
//    CCLayer * pLayer = new TestController();
    
//    pLayer->autorelease();

//    pScene->addChild(pLayer);
    
//    CCScene* pScene = CCScene::create();
    CCScene* pScene = SceneEditorTestLayer::scene();
    pDirector->runWithScene(pScene);

    pDirector->setDisplayStats(false);
    return true;
}
开发者ID:253627764,项目名称:CocoStudioTutorials,代码行数:43,代码来源:AppDelegate.cpp

示例9: preVisitWithClippingRect

//---------------------------------------------------------------
//
//
void CLetterMoveLayer::preVisitWithClippingRect(CCRect clipRect)
{
    if (!this->getIsVisible())
        return;
	
    glEnable(GL_SCISSOR_TEST);
	
    CCDirector *director = CCDirector::sharedDirector();
    CCSize size =director->getWinSize();
    CCPoint origin = this->convertToWorldSpaceAR(clipRect.origin);
    CCPoint topRight =this->convertToWorldSpaceAR(ccpAdd(clipRect.origin, ccp(clipRect.size.width, clipRect.size.height)));
    CCRect scissorRect = CCRectMake(origin.x, origin.y, topRight.x-origin.x, topRight.y-origin.y);
	
    // transform the clipping rectangle to adjust to the current screen
    // orientation: the rectangle that has to be passed into glScissor is
    // always based on the coordinate system as if the device was held with the
    // home button at the bottom. the transformations account for different
    // device orientations and adjust the clipping rectangle to what the user
    // expects to happen.
    ccDeviceOrientation orientation =director->getDeviceOrientation();
    switch (orientation) {
        case kCCDeviceOrientationPortrait:
            break;
        case kCCDeviceOrientationPortraitUpsideDown:
            scissorRect.origin.x = size.width-scissorRect.size.width-scissorRect.origin.x;
            scissorRect.origin.y = size.height-scissorRect.size.height-scissorRect.origin.y;
            break;
        case kCCDeviceOrientationLandscapeLeft:
        {
            float tmp = scissorRect.origin.x;
            scissorRect.origin.x = scissorRect.origin.y;
            scissorRect.origin.y = size.width-scissorRect.size.width-tmp;
            tmp = scissorRect.size.width;
            scissorRect.size.width = scissorRect.size.height; 
            scissorRect.size.height = tmp;
        }
            break;
        case kCCDeviceOrientationLandscapeRight:
        {
            float tmp = scissorRect.origin.y;
            scissorRect.origin.y = scissorRect.origin.x;
            scissorRect.origin.x = size.height-scissorRect.size.height-tmp;
            tmp = scissorRect.size.width;
            scissorRect.size.width = scissorRect.size.height;
            scissorRect.size.height = tmp;
        }
            break;
    }
	
    // Handle Retina
    scissorRect = CC_RECT_POINTS_TO_PIXELS(scissorRect);
	
    glScissor((GLint) scissorRect.origin.x, (GLint) scissorRect.origin.y,
              (GLint) scissorRect.size.width, (GLint) scissorRect.size.height);
}
开发者ID:JoeHu,项目名称:magicpet,代码行数:58,代码来源:CGameLetter.cpp

示例10: applicationDidFinishLaunching

bool AppDelegate::applicationDidFinishLaunching() {
    // initialize director
    CCDirector* pDirector = CCDirector::sharedDirector();
    CCEGLView* pEGLView = CCEGLView::sharedOpenGLView();

    pDirector->setOpenGLView(pEGLView);
	CCSize frameSize = pEGLView->getFrameSize();
    
    // enable High Resource Mode(2x, such as iphone4) and maintains low resource on other devices.
    TargetPlatform target = getTargetPlatform();
    if(target == kTargetIpad)
    {
        // ipad
        if(pDirector->enableRetinaDisplay(true))
        {
            // ipad hd
            CCFileUtils::sharedFileUtils()->setResourceDirectory("ipadhd");
        }
        else
        {
            CCFileUtils::sharedFileUtils()->setResourceDirectory("ipad");
        }
    }
    else if(target == kTargetIphone)
    {
        // iphone
        if(pDirector->enableRetinaDisplay(true))
        {
            if(pDirector->getWinSize().width > 480)
            {
                // iphone hd 4'
                CCFileUtils::sharedFileUtils()->setResourceDirectory("iphone");
            }
            else
            {
                // iphone hd 3'
                CCFileUtils::sharedFileUtils()->setResourceDirectory("iphone");
            }
        }
    }
	
    // 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);

    // create a scene. it's an autorelease object
    CCScene *pScene = HelloWorld::scene();

    // run
    pDirector->runWithScene(pScene);

    return true;
}
开发者ID:haxpor,项目名称:ObjectAL-CppWrapper,代码行数:55,代码来源:AppDelegate.cpp

示例11: ccTouchMoved

void CCScene::ccTouchMoved(CCTouch *pTouch, CCEvent *pEvent) {
    if(!mEnableSlideBack)
        return;
    CCPoint start = pTouch->getStartLocation();
    CCPoint end = pTouch->getLocation();
    CCDirector *d = CCDirector::sharedDirector();
    float w = d->getWinSize().width;
    if (start.x - end.x < -w/3.0f){
        scheduleOnce(schedule_selector(CCScene::delayBack), 0.0f);
    }
}
开发者ID:saranpol,项目名称:cocos2d-x,代码行数:11,代码来源:CCScene.cpp

示例12: init

bool CCScene::init()
{
    bool bRet = false;
     do 
     {
         CCDirector * pDirector;
         CC_BREAK_IF( ! (pDirector = CCDirector::sharedDirector()) );
         this->setContentSize(pDirector->getWinSize());
         // success
         bRet = true;
     } while (0);
     return bRet;
}
开发者ID:SD216814,项目名称:quick-cocos2d-x,代码行数:13,代码来源:CCScene.cpp

示例13: init

bool MapScene::init()
{
	bool inited = false;
	do 
	{
		CCDirector * pDirector;
		CC_BREAK_IF(! (pDirector = CCDirector::sharedDirector()) );
		this->setContentSize(pDirector->getWinSize());

		inited = true;
	} while (0);
	return inited;
}
开发者ID:spzktshow,项目名称:isoMap,代码行数:13,代码来源:MapView.cpp

示例14: draw

void MapTileLayer::draw()
{
	if (map)
	{
		CHECK_GL_ERROR_DEBUG();
		CCDirector* direct = CCDirector::sharedDirector();
		int i = 0;
		CCSize mapTotalSize;
		mapTotalSize.width = map->nodeData->matrix->col * map->nodeSize->width;
		mapTotalSize.height = map->nodeData->matrix->row * map->nodeSize->height;
		for (i = 0; i <= map->nodeData->matrix->col; i ++)
		{
			MSPoint3D startP(i * map->nodeSize->width, 0, 0);
			MSPoint3D endP(i * map->nodeSize->width, 0, mapTotalSize.height);
			CCPoint sp = MapUtils::convertScreen(startP);
			CCPoint ep = MapUtils::convertScreen(endP);
			sp.y = CoordinateUtils::calculateCoordinateSystem(sp.y, direct->getWinSize());
			ep.y = CoordinateUtils::calculateCoordinateSystem(ep.y, direct->getWinSize());
			ccDrawLine(sp, ep);	
		}
		for (i = 0; i <= map->nodeData->matrix->row; i ++)
		{
			MSPoint3D startQ(0, 0, i * map->nodeSize->height);
			MSPoint3D endQ(mapTotalSize.width, 0, i * map->nodeSize->height);
			CCPoint sq = MapUtils::convertScreen(startQ);
			CCPoint eq = MapUtils::convertScreen(endQ);
			sq.y = CoordinateUtils::calculateCoordinateSystem(sq.y, direct->getWinSize());
			eq.y = CoordinateUtils::calculateCoordinateSystem(eq.y, direct->getWinSize());
			ccDrawLine(sq, eq);
		}
		CHECK_GL_ERROR_DEBUG();
	}
	else
	{
		CCLayer::draw();
	}

}
开发者ID:spzktshow,项目名称:isoMap,代码行数:38,代码来源:MapView.cpp

示例15: init

// on "init" you need to initialize your instance
bool HelloWorld::init()
{
    //////////////////////////////
    // 1. super init first
    if ( !CCLayerColor::initWithColor(ccc4(255, 255, 255, 255)))
    {
        return false;
    }

    /////////////////////////////
    // 2. add a menu item with "X" image, which is clicked to quit the program
    //    you may modify it.

    // add a "close" icon to exit the progress. it's an autorelease object
    CCMenuItemImage *pCloseItem = CCMenuItemImage::create(
                                        "CloseNormal.png",
                                        "CloseSelected.png",
                                        this,
                                        menu_selector(HelloWorld::menuCloseCallback) );
    pCloseItem->setPosition( ccp(CCDirector::sharedDirector()->getWinSize().width - 20, 20) );

    // create menu, it's an autorelease object
    CCMenu* pMenu = CCMenu::create(pCloseItem, NULL);
    pMenu->setPosition( CCPointZero );
    this->addChild(pMenu, 1);

    /////////////////////////////
    // 3. add your codes below...

    // add a label shows "Hello World"
    // create and initialize a label
    CCDirector* dir = CCDirector::sharedDirector();
    CCSize winsize = dir->getWinSize();
    
    CCLabelTTF* pLabel = CCLabelTTF::create("Hello World", "Thonburi", 34);
    pLabel->setPosition(ccp(winsize.width/2, winsize.height - 30));
    this->addChild(pLabel);
    
    CCSprite* player = CCSprite::create("Player.png");
    player->setPosition(ccp(player->getContentSize().width/2, winsize.height/2));
    this->addChild(player);
    
    this->schedule(schedule_selector(HelloWorld::Update_CreatedEnemy), 1.0f);
    this->scheduleUpdate();
    this->setTouchEnabled(true);
    
    CocosDenshion::SimpleAudioEngine::sharedEngine()->playBackgroundMusic("background-music-aac.wav", true);
    
    return true;
}
开发者ID:bwjdrl2,项目名称:Test,代码行数:51,代码来源:HelloWorldScene.cpp


注:本文中的CCDirector::getWinSize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。