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


C++ Director类代码示例

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


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

示例1: addChild

bool HighscoreLayer::init() {
    if(!LayerColor::init()) {
        return false;
    }
    
    Director* director = Director::getInstance();
    Vec2 visibleOrigin = director->getVisibleOrigin();
    Size visibleSize = director->getVisibleSize();
    
    //    setContentSize(visibleSize);
    
    Widget* root = GUIReader::getInstance()->widgetFromJsonFile("ui/connect/high_score.json");
    addChild(root);
    root->setContentSize(visibleSize);
    
    Node* content = root->getChildByName("content");
    content->setPositionY((visibleSize.height-content->getContentSize().height)/2);
    
    
    Text* endlessHighscoreLabel = dynamic_cast<Text*>(content->getChildByName("endlessHighScoreLabel"));
    endlessHighscoreLabel->setString(LANG->getLang("high_score_endless_label"));
    
    Text* endlessHighscoreText = dynamic_cast<Text*>(content->getChildByName("endlessHighscoreText"));
    endlessHighscoreText->setString(StringUtils::format("%d", UserData::getInstance()->getEndlessHighscore()));
    
    Text* classicHighscoreLabel = dynamic_cast<Text*>(content->getChildByName("classicHighScoreLabel"));
    classicHighscoreLabel->setString(LANG->getLang("high_score_classic_label"));
    
    Text* classicHighscoreText = dynamic_cast<Text*>(content->getChildByName("classicHighscoreText"));
    classicHighscoreText->setString(StringUtils::format("%d", UserData::getInstance()->getClassicHighscore()));
    
    Util::registerButton(root, "back", [=](Ref* ref,Widget::TouchEventType event){
        switch (event) {
            case cocos2d::ui::Widget::TouchEventType::ENDED:
            {
                Director::getInstance()->replaceScene(MainMenuLayer::createScene());
            }
                break;
            default:
                break;
        }
    }, "");
    Node* backButton = root->getChildByName("back");
    auto backButtonSize = backButton->getContentSize();
    backButton->setPosition(backButtonSize.width/2+20, visibleSize.height-backButtonSize.height/2 - 15);
    
    Text* title = dynamic_cast<Text*>(content->getChildByName("title"));
    title->setString(LANG->getLang("high_score_title"));
    
    return true;
}
开发者ID:newcl,项目名称:connect,代码行数:51,代码来源:high_score_layer.cpp

示例2: onBegin

void RenderTexture::onBegin()
{
    //
    Director *director = Director::getInstance();
    
    _oldProjMatrix = director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION);
    director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION, _projectionMatrix);
    
    _oldTransMatrix = director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
    director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, _transformMatrix);
    
    if(!_keepMatrix)
    {
        director->setProjection(director->getProjection());
        const Size& texSize = _texture->getContentSizeInPixels();
        
        // Calculate the adjustment ratios based on the old and new projections
        Size size = director->getWinSizeInPixels();
        float widthRatio = size.width / texSize.width;
        float heightRatio = size.height / texSize.height;
        
        Mat4 orthoMatrix;
        Mat4::createOrthographicOffCenter((float)-1.0 / widthRatio, (float)1.0 / widthRatio, (float)-1.0 / heightRatio, (float)1.0 / heightRatio, -1, 1, &orthoMatrix);
        director->multiplyMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION, orthoMatrix);
    }
    
    //calculate viewport
    {
        Rect viewport;
        viewport.size.width = _fullviewPort.size.width;
        viewport.size.height = _fullviewPort.size.height;
        float viewPortRectWidthRatio = float(viewport.size.width)/_fullRect.size.width;
        float viewPortRectHeightRatio = float(viewport.size.height)/_fullRect.size.height;
        viewport.origin.x = (_fullRect.origin.x - _rtTextureRect.origin.x) * viewPortRectWidthRatio;
        viewport.origin.y = (_fullRect.origin.y - _rtTextureRect.origin.y) * viewPortRectHeightRatio;
        //glViewport(_fullviewPort.origin.x, _fullviewPort.origin.y, (GLsizei)_fullviewPort.size.width, (GLsizei)_fullviewPort.size.height);
        glViewport(viewport.origin.x, viewport.origin.y, (GLsizei)viewport.size.width, (GLsizei)viewport.size.height);
    }

    // Adjust the orthographic projection and viewport
    
    glGetIntegerv(GL_FRAMEBUFFER_BINDING, &_oldFBO);
    glBindFramebuffer(GL_FRAMEBUFFER, _FBO);

    // TODO: move this to configuration, so we don't check it every time
    /*  Certain Qualcomm Adreno GPU's will retain data in memory after a frame buffer switch which corrupts the render to the texture. The solution is to clear the frame buffer before rendering to the texture. However, calling glClear has the unintended result of clearing the current texture. Create a temporary texture to overcome this. At the end of RenderTexture::begin(), switch the attached texture to the second one, call glClear, and then switch back to the original texture. This solution is unnecessary for other devices as they don't have the same issue with switching frame buffers.
     */
    if (Configuration::getInstance()->checkForGLExtension("GL_QCOM"))
    {
        // -- bind a temporary texture so we can clear the render buffer without losing our texture
        glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, _textureCopy->getName(), 0);
        CHECK_GL_ERROR_DEBUG();
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
        glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, _texture->getName(), 0);
    }
}
开发者ID:zengzhining,项目名称:cocos2d-x,代码行数:56,代码来源:CCRenderTexture.cpp

示例3: win

void SpriteManager::win()
{
	batchNode->removeChild(allSp[0],true);

	Director *director = Director::getInstance();
	director->pause();//暂停各种运动

	createSprite(NULL, Rect(419,652,619-419,708-652), batchNode, 0.5, 0.5, WIDTH/2, HEIGHT/2, 500, 200, PauseBGZOrder+1);

	//左上角 的返回键按钮
	allSp[23] = createSprite(NULL, Rect(871,154,910-871,186-154), batchNode, 0.5f, 0.5f, 45, 540-37, 63, 55, GoBackZOrder);
	allSp[23]->setRotation(-90.0f);
	AddEventListenerSprite(allSp[23]);
}
开发者ID:ns-xlz,项目名称:ns-xlz-cocos,代码行数:14,代码来源:SpriteManager.cpp

示例4: end

void RenderTexture::end()
{
    Director *director = Director::getInstance();
    
    glBindFramebuffer(GL_FRAMEBUFFER, _oldFBO);

    // restore viewport
    director->setViewport();

    kmGLMatrixMode(KM_GL_PROJECTION);
	kmGLPopMatrix();
	kmGLMatrixMode(KM_GL_MODELVIEW);
	kmGLPopMatrix();
}
开发者ID:0x0c,项目名称:cocos2d-x,代码行数:14,代码来源:CCRenderTexture.cpp

示例5: _rotationX

Node::Node(void)
: _rotationX(0.0f)
, _rotationY(0.0f)
, _scaleX(1.0f)
, _scaleY(1.0f)
, _vertexZ(0.0f)
, _position(Point::ZERO)
, _skewX(0.0f)
, _skewY(0.0f)
, _anchorPointInPoints(Point::ZERO)
, _anchorPoint(Point::ZERO)
, _contentSize(Size::ZERO)
, _additionalTransform(AffineTransformMakeIdentity())
, _camera(NULL)
// children (lazy allocs)
// lazy alloc
, _grid(NULL)
, _ZOrder(0)
, _children(NULL)
, _parent(NULL)
// "whole screen" objects. like Scenes and Layers, should set _ignoreAnchorPointForPosition to true
, _tag(kNodeTagInvalid)
// userData is always inited as nil
, _userData(NULL)
, _userObject(NULL)
, _shaderProgram(NULL)
, _GLServerState(ccGLServerState(0))
, _orderOfArrival(0)
, _running(false)
, _transformDirty(true)
, _inverseDirty(true)
, _additionalTransformDirty(false)
, _visible(true)
, _ignoreAnchorPointForPosition(false)
, _reorderChildDirty(false)
, _isTransitionFinished(false)
, _updateScriptHandler(0)
, _componentContainer(NULL)
{
    // set default scheduler and actionManager
    Director *director = Director::getInstance();
    _actionManager = director->getActionManager();
    _actionManager->retain();
    _scheduler = director->getScheduler();
    _scheduler->retain();

    ScriptEngineProtocol* pEngine = ScriptEngineManager::getInstance()->getScriptEngine();
    _scriptType = pEngine != NULL ? pEngine->getScriptType() : kScriptTypeNone;
    _componentContainer = new ComponentContainer(this);
}
开发者ID:Ben-Cortina,项目名称:GameBox,代码行数:50,代码来源:CCNode.cpp

示例6: setRequest

void HealthMonitor::update() {
  Director* director = static_cast<Director*>(backend_->manager());

  setRequest(
      "GET %s HTTP/1.1\r\n"
      "Host: %s\r\n"
      "x0-Health-Check: yes\r\n"
      "x0-Director: %s\r\n"
      "x0-Backend: %s\r\n"
      "\r\n",
      director->healthCheckRequestPath().c_str(),
      director->healthCheckHostHeader().c_str(), director->name().c_str(),
      backend_->name().c_str());
}
开发者ID:tempbottle,项目名称:x0,代码行数:14,代码来源:HealthMonitor.cpp

示例7: main

int main() {
	Director* d = new Director();
	d->setBuilder(new dfBuilder());
	d->orderCake("sacher");
	d->orderCake("tresLeches");
	d->orderCake("imposible");
	d->orderCake("imposible");
	d->orderCake("imposible");
	d->printCakes();
	std::cout << "Tenemos " << d->getCakesCount() << " pasteles" << std::endl;
	std::cout << "Hay un imposible en la posicion " << d->searchCake("imposible") << std::endl;
	d->searchCake("tresLeches");
	return 0;
}
开发者ID:osanseviero,项目名称:Software_Engineering,代码行数:14,代码来源:main.cpp

示例8: rewardPlayer

void Enemy::die()
{
    rewardPlayer();
    // initialize director
    Director *pDirector = Director::getInstance();
    
    // create a scene. it's an autorelease object
    Scene *pScene = VictoryScene::scene();
    
    // run
    pDirector->pushScene(pScene);
    //delete player;
    //delete this;
}
开发者ID:Enniwhere,项目名称:BookBattleMultiplatform,代码行数:14,代码来源:Enemy.cpp

示例9: addBackground

//------------------------------------------------------------------
//
// MainGameLayer3
//
//------------------------------------------------------------------
bool MainGameLayer3::init()
{
	iMaxFeet = MAX_DIVE_FEET_AT_ONE_SCENE;
	iTagForMarinelife = kTagLayerSquid;

	// Add background sprite
	addBackground();

	// Touch
	Director* director = Director::getInstance();
    director->getTouchDispatcher()->addTargetedDelegate(this, 0, true);

	return true;
}
开发者ID:rtothecore,项目名称:GrandBlue,代码行数:19,代码来源:MainGameScene3.cpp

示例10: finish

void GalderaScene::finish()
{
    multzoa->kalifikazioa = kalifikazioa;
    multzoa->currentGaldera = currentGalderaPosition;
    multzoa->bukatuta = 1;
    
    pSQL->updateErabiltzaileMultzoa(multzoa);
    
    BukatutaScene *scene = BukatutaScene::create(multzoa);
    
    Director *pDirector = Director::getInstance();
    TransitionFade *tscene = TransitionFade::create(0.5, scene);
    pDirector->replaceScene(tscene);
}
开发者ID:irontec,项目名称:Jakina-mobile,代码行数:14,代码来源:GalderaScene.cpp

示例11: backButton

void GalderaScene::backButton(Ref* sender)
{
    multzoa->kalifikazioa = kalifikazioa;
    multzoa->currentGaldera = currentGalderaPosition;
    multzoa->bukatuta = 0;
    
    pSQL->updateErabiltzaileMultzoa(multzoa);
    
    CategoryScene *scene = CategoryScene::create();
    
    Director *pDirector = Director::getInstance();
    TransitionFade *tscene = TransitionFade::create(0.5, scene);
    pDirector->replaceScene(tscene);
}
开发者ID:irontec,项目名称:Jakina-mobile,代码行数:14,代码来源:GalderaScene.cpp

示例12: beforeDraw

void GridBase::beforeDraw(void)
{
    // save projection
    Director *director = Director::getInstance();
    _directorProjection = director->getProjection();

    // 2d projection
    //    [director setProjection:Director::Projection::_2D];
    set2DProjection();
    
    Size    size = director->getWinSizeInPixels();
    glViewport(0, 0, (GLsizei)(size.width), (GLsizei)(size.height) );
    _grabber->beforeRender(_texture);
}
开发者ID:1005491398,项目名称:Threes,代码行数:14,代码来源:CCGrid.cpp

示例13: Update

void SSGun::Update(Director &director, int timePassed) {
    float xw = -(director.InputServiceInstance().mouseX - 360) * 1.5f / 75.0f;
    this->SetCenter(SSPointMake(xw, -3.5f, 10.0f));
    
    lastShotFiredTime += timePassed;
    
    // change to if mouse down
    if (director.InputServiceInstance().isMouseDown && lastShotFiredTime > 300) {
        lastShotFiredTime = 0;
        SSBullet *bullet = new SSBullet();
        bullet->SetCenter(this->GetCenter());
        this->GetScene()->AddActor(bullet);
    }
}
开发者ID:shoerob,项目名称:SSGameBuilder,代码行数:14,代码来源:SSGun.cpp

示例14: CCASSERT

void Box2DView::onDraw(const Mat4 &transform, uint32_t flags)
{
    Director* director = Director::getInstance();
    CCASSERT(nullptr != director, "Director is null when seting matrix stack");
    director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
    director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, transform);

    GL::enableVertexAttribs( cocos2d::GL::VERTEX_ATTRIB_FLAG_POSITION );
    m_test->Step(&settings);
    m_test->m_world->DrawDebugData();
    CHECK_GL_ERROR_DEBUG();
    
    director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
}
开发者ID:anilgulgor,项目名称:myGame,代码行数:14,代码来源:Box2dView.cpp

示例15: loadOnlyMap

bool loadOnlyMap(string location){
	Director director;
	MapBuilder* mapWithoutPlayersBuilder = new MapWithoutPlayers;
	director.setMapBuilder(mapWithoutPlayersBuilder);

	if (director.constructMap(location)){
		mainMap = director.getMap();
		return true;
	}
	else{
		return false;
	}

}
开发者ID:mchmilar,项目名称:RiskGroup,代码行数:14,代码来源:Driver.cpp


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