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


C++ setTexture函数代码示例

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


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

示例1: setEmitterMode

bool ParticleHitEmitter::initWithTotalParticles(unsigned int numberOfPartiles)
{
	if (CCParticleSystemQuad::initWithTotalParticles(numberOfPartiles))
	{
		// duration
		m_fDuration = 0.1f;

		setEmitterMode(kCCParticleModeGravity);

		// Gravity Mode: gravity
		setGravity(ccp(0, 0));

		// Gravity Mode: speed of particles
		setSpeed(0);
		setSpeedVar(0);

		// Gravity Mode: radial
		setRadialAccel(0);
		setRadialAccelVar(0);

		// Gravity Mode: tangential
		setTangentialAccel(0);
		setTangentialAccelVar(0);

		// angle
		m_fAngle = 90;
		m_fAngleVar = 360;

		// emitter position
		CCSize winSize = CCDirector::sharedDirector()->getWinSize();
		this->setPosition(ccp(winSize.width / 2, winSize.height / 2));
		setPosVar(CCPointZero);

		// life of particles
		m_fLife = 0.1f;
		m_fLifeVar = 0;

		// size, in pixels
		m_fStartSize = 100;
		m_fStartSizeVar = 0.0f;
		m_fEndSize = 300;

		// emits per second
		m_fEmissionRate = m_uTotalParticles / m_fDuration;
		//m_uTotalParticles = 50;
		// color of particles
		m_tStartColor.r = 1.0f;
		m_tStartColor.g = 1.0f;
		m_tStartColor.b = 1.0f;
		m_tStartColor.a = 1.0f;
		m_tStartColorVar.r = 0.0f;
		m_tStartColorVar.g = 0.0f;
		m_tStartColorVar.b = 0.0f;
		m_tStartColorVar.a = 0.0f;
		m_tEndColor.r = 1.0f;
		m_tEndColor.g = 1.0f;
		m_tEndColor.b = 1.0f;
		m_tEndColor.a = 0.0f;
		m_tEndColorVar.r = 0.0f;
		m_tEndColorVar.g = 0.0f;
		m_tEndColorVar.b = 0.0f;
		m_tEndColorVar.a = 0.0f;

		setTexture(CCTextureCache::sharedTextureCache()->addImage("./Data/fire.png"));//.pvr");

		// additive
		this->setBlendAdditive(true);
		mLayer->addChild(this);
		return true;
	}
	return false;
}
开发者ID:ECNU-ZR,项目名称:physwf-c-lab,代码行数:72,代码来源:PartileEmitter.cpp

示例2: m_texture

Sprite::Sprite(const Texture& texture) :
m_texture    (NULL),
m_textureRect()
{
    setTexture(texture);
}
开发者ID:42bottles,项目名称:SFML,代码行数:6,代码来源:Sprite.cpp

示例3: getContext

void HelpState::addPlankton(PlanktonController::Type type)
{
    auto entity = std::make_unique<Entity>(m_messageBus);
    entity->setWorldPosition({ static_cast<float>(Util::Random::value(0, 1920)), static_cast<float>(Util::Random::value(0, 1080)) });

    auto physComponent = m_physWorld.addBody(planktonSize);
    physComponent->setPosition(entity->getWorldPosition());
    physComponent->setTriggerOnly(true);
    physComponent->setName("control");
    entity->addComponent<PhysicsComponent>(physComponent);

    auto& appInstance = getContext().appInstance;
    bool colourblind = appInstance.getGameSettings().colourblindMode;
    AnimatedDrawable::Ptr ad;
    auto ident = ParticleSystem::create(Particle::Type::Ident, m_messageBus);
    ident->setTexture(appInstance.getTexture("assets/images/particles/ident.png"));
    auto text = std::make_unique<TextDrawable>(m_messageBus);
    text->setFont(appInstance.getFont("assets/fonts/Ardeco.ttf"));
    switch (type)
    {
    case PlanktonController::Type::Good:
        ad = std::make_unique<AnimatedDrawable>(m_messageBus, appInstance.getTexture("assets/images/player/food01.png"));
        ad->loadAnimationData("assets/images/player/food01.cra");
        (colourblind) ? ident->setColour({ 14u, 160u, 225u }) : ident->setColour({ 84u, 150u, 75u });
        text->setString("+50 HP");
        break;
    case PlanktonController::Type::Bad:
        ad = std::make_unique<AnimatedDrawable>(m_messageBus, appInstance.getTexture("assets/images/player/food02.png"));
        ad->loadAnimationData("assets/images/player/food02.cra");
        (colourblind) ? ident->setColour({ 214u, 190u, 25u }) : ident->setColour({ 184u, 67u, 51u });
        text->setString("-35 HP");
        break;
    case PlanktonController::Type::Bonus:
        ad = std::make_unique<AnimatedDrawable>(m_messageBus, appInstance.getTexture("assets/images/player/food03.png"));
        ad->loadAnimationData("assets/images/player/food03.cra");
        ident->setColour({ 158u, 148u, 224u });
        text->setString("+100 HP");
        break;
    case PlanktonController::Type::UberLife:
        ad = std::make_unique<AnimatedDrawable>(m_messageBus, appInstance.getTexture("assets/images/player/bonus.png"));
        ad->loadAnimationData("assets/images/player/bonus.cra");
        ident->setColour({ 158u, 148u, 224u });
        text->setString("FULL HEALTH");
        break;
    default:
        break;
    }
    ident->setName("ident");
    entity->addComponent<ParticleSystem>(ident);

    text->setCharacterSize(40u);
    Util::Position::centreOrigin(*text);
    text->setPosition(0.f, 40.f);
    text->setName("text");
    entity->addComponent<TextDrawable>(text);

    ad->setBlendMode(sf::BlendAdd);
    ad->setOrigin(sf::Vector2f(ad->getFrameSize()) / 2.f);
    if (!ad->getAnimations().empty()) ad->play(ad->getAnimations()[0]);
    ad->setName("drawable");
    entity->addComponent<AnimatedDrawable>(ad);

    auto trail = ParticleSystem::create(Particle::Type::Trail, m_messageBus);
    trail->setTexture(appInstance.getTexture("assets/images/particles/circle.png"));
    float particleSize = planktonSize / 12.f;
    trail->setParticleSize({ particleSize, particleSize });
    trail->setName("trail");
    trail->setEmitRate(10.f);
    entity->addComponent<ParticleSystem>(trail);

    if (type == PlanktonController::Type::UberLife)
    {
        auto tails = std::make_unique<TailDrawable>(m_messageBus);
        tails->addTail(sf::Vector2f(-18.f, -15.f));
        tails->addTail(sf::Vector2f(-8.f, -5.f));
        tails->addTail(sf::Vector2f(-8.f, 5.f));
        tails->addTail(sf::Vector2f(-18.f, 15.f));
        tails->setName("tail");
        entity->addComponent<TailDrawable>(tails);
    }

    auto controller = std::make_unique<PlanktonController>(m_messageBus);
    controller->setType(type);
    controller->setDecayRate(0.f);
    controller->setColourblind(colourblind);
    entity->addComponent<PlanktonController>(controller);

    m_rootNode.addChild(entity);
}
开发者ID:JonnyPtn,项目名称:pseuthe,代码行数:89,代码来源:HelpState.cpp

示例4: ActiveUI

Animation::Animation(std::string frmName, unsigned int direction) : ActiveUI()
{
    auto frm = ResourceManager::frmFileType(frmName);
    setTexture(ResourceManager::texture(frmName));


    int xOffset = frm->shiftX(direction);
    int yOffset = frm->shiftY(direction);


    // Смещение кадра в текстуре анимации
    unsigned int x = 0;
    unsigned int y = 0;

    for (unsigned int d = 0; d != direction; ++d)
    {
        y += frm->height(d); //? может i - 1
    }


    for (auto f = 0; f != frm->framesPerDirection(); ++f)
    {
        xOffset += frm->offsetX(direction, f);
        yOffset += frm->offsetY(direction, f);

        auto frame = new AnimationFrame();
        frame->setWidth(frm->width(direction, f));
        frame->setHeight(frm->height(direction, f));
        frame->setXOffset(xOffset);
        frame->setYOffset(yOffset);
        frame->setY(y);
        frame->setX(x);

        auto fps = frm->framesPerSecond();
        if (fps == 0)
        {
            frame->setDuration(1000);
        }
        else
        {
            frame->setDuration(std::round(1000.0/static_cast<double>(frm->framesPerSecond())));
        }

        x += frm->width(direction);
        frames()->push_back(frame);
    }

    if (frm->animatedPalette())
    {
        AnimatedPalette*  palette=Game::getInstance()->animatedPalette();
        auto masks = frm->animatedMasks();

        if ((*masks)[libfalltergeist::FrmFileType::MASK_MONITOR] != NULL)
        {
            for (auto i=0; i<5; i++)
            {
                unsigned int* mask = new unsigned int[frm->width() * frm->height()]();

                //modify
                for (unsigned int j = 0; j< frm->width() * frm->height(); j++)
                {
                    mask[j] = palette->color((*masks)[libfalltergeist::FrmFileType::MASK_MONITOR][j],i);
                }
                //set
                auto texture = new Texture(frm->width(), frm->height());
                texture->loadFromRGBA(mask);
                _monitorTextures.push_back(texture);
            }
        }

        if ((*masks)[libfalltergeist::FrmFileType::MASK_SLIME] != NULL)
        {
            for (auto i=0; i<4; i++)
            {
                unsigned int* mask = new unsigned int[frm->width() * frm->height()]();	

                //modify
                for (unsigned int j = 0; j< frm->width() * frm->height(); j++)
                {
                    mask[j] = palette->color(((*masks)[libfalltergeist::FrmFileType::MASK_SLIME][j]),i);
                }
                //set
                auto texture = new Texture(frm->width(), frm->height());
                texture->loadFromRGBA(mask);
                _slimeTextures.push_back(texture);
            }
        }

        if ((*masks)[libfalltergeist::FrmFileType::MASK_SHORE] != NULL)
        {
            for (auto i=0; i<6; i++)
            {
                unsigned int* mask = new unsigned int[frm->width() * frm->height()]();

                //modify
                for (unsigned int j = 0; j< frm->width() * frm->height(); j++)
                {
                    mask[j] = palette->color(((*masks)[libfalltergeist::FrmFileType::MASK_SHORE][j]),i);
                }
                //set
//.........这里部分代码省略.........
开发者ID:smaximov,项目名称:falltergeist,代码行数:101,代码来源:Animation.cpp

示例5: setTexture

void LayerTile::updateContents(BlackBerry::Platform::Graphics::Buffer* contents, double scale)
{
    m_scale = scale;
    setTexture(textureCacheCompositingThread()->updateContents(m_texture, contents));
}
开发者ID:SchleunigerAG,项目名称:WinEC7_Qt5.3.1_Fixes,代码行数:5,代码来源:LayerTile.cpp

示例6: TexturedShowable

 Selection::Selection(engine::graphics::Texture* texture, int size) :
     TexturedShowable(texture->getDimensions() * size, engine::Vector2d(texture->getDimensions().getX() * size / 2, texture->getDimensions().getY() / 2))
 {
     setTexture(texture);
 }
开发者ID:mcdooda,项目名称:The-Global-Scourge,代码行数:5,代码来源:selection.cpp

示例7: assert

    std::shared_ptr<TextureAtlas> GdxTextureAtlasLoader::load(std::istream& in) const
    {
        assert(_textureManager);

        auto atlas = std::make_shared<TextureAtlas>();
        std::string line;

        // texture name
        while(line.empty())
        {
            std::getline(in, line);
            StringUtils::trim(line);
        }
        if(_textureManager)
        {
            atlas->setTexture(_textureManager->load(line));
        }

        bool inRegion = false;
        TextureRegion region;

        while(in)
        {
            std::getline(in, line);
            std::size_t sep = line.find(':');
            std::string n = line.substr(0, sep);
            std::string v = line.substr(sep+1);

            if(!inRegion)
            {
                if(sep == std::string::npos)
                {
                    inRegion = true;
                    region = TextureRegion();
                    region.name = line;
                }
                else
                {
                    // header value
                }
            }
            else
            {
                if(line.substr(0, 1) == " ")
                {
                    StringUtils::trim(n);
                    StringUtils::trim(v);
                    if(n == "rotate")
                    {
                        region.rotate = v == "true";
                    }
                    else if(n == "xy")
                    {
                        sep = v.find(',');                       
                        region.x = std::stoi(v.substr(0, sep));
                        region.y = std::stoi(v.substr(sep+1));
                    }
                    else if(n == "size")
                    {
                        sep = v.find(',');
                        region.width = std::stoi(v.substr(0, sep));
                        region.height = std::stoi(v.substr(sep+1));
                    }
                    else if(n == "orig")
                    {
                        sep = v.find(',');
                        region.originalWidth = std::stoi(v.substr(0, sep));
                        region.originalHeight = std::stoi(v.substr(sep+1));
                    }
                    else if(n == "offset")
                    {
                        sep = v.find(',');
                        region.offsetX = std::stoi(v.substr(0, sep));
                        region.offsetY = std::stoi(v.substr(sep+1));
                    }
                    else if(n == "index")
                    {
                        region.index = std::stoi(v);
                    }
                }
                else
                {
                    region.origin = TextureRegion::Origin::TopLeft;
                    atlas->addRegion(region);
                    region = TextureRegion();
                    region.name = line;
                }             
            }
        }

        return std::move(atlas);
    }
开发者ID:respu,项目名称:mvcgame,代码行数:92,代码来源:GdxTextureAtlasLoader.cpp

示例8: display

void display(void)
{
 	//時間計測
  curTime = timeGetTime();
  float dt = (float)(curTime - lastTime) * 0.001;//secに変換
  elapseTime1 += dt;
  elapseTime2 += dt;
  fps ++;
		printf("elapseTime2 = %f \n", elapseTime2);
  if(elapseTime1 >= 1.0)
  {
		printf("frame per sec = %d \n", fps);
		elapseTime1 = 0.0;
		fps = 0;
  }
  lastTime = curTime;

	//波データを作成し、投影マップを設定
	if(kindWave == 0) makeWaveCircle(amp, elapseTime2);
	else if(kindWave == 1) makeWavePlane(amp, elapseTime2);
	else makeWaveMix(amp, elapseTime2);
	makeTexImage();
	setTexture();

  if(flagWireframe)//'w'でwireframeとsolid model切り替え
  {
	  glPolygonMode(GL_FRONT,GL_LINE);
	  glPolygonMode(GL_BACK,GL_POINT);
  }
  else glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);

	resize(width, height);
	//カラーバッファのクリア
  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

  if(cos(M_PI * view.theta /180.0) > 0.0)//カメラ仰角90度でビューアップベクトル切替
	  gluLookAt(view.pos[0], view.pos[1], view.pos[2], view.cnt[0], view.cnt[1], view.cnt[2], 0.0, 1.0, 0.0);
  else
	  gluLookAt(view.pos[0], view.pos[1], view.pos[2], view.cnt[0], view.cnt[1], view.cnt[2], 0.0, -1.0, 0.0);

  //光源設定//'l'を押した後光源位置可変
  glLightfv(GL_LIGHT0, GL_POSITION, lightPos);

  //fragment shaderのユニフォーム変数インデックスを取得
  GLint texLoc = glGetUniformLocation(shaderProg, "smplCaustics");
  glUniform1i(texLoc, 0);//GL_TEXTURE0を適用
  // シェーダプログラムの適用 
  glUseProgram(shaderProg);

  //描画
	fish1.motion1(elapseTime2);
	fish2.motion1(elapseTime2);
	drawFloor0(10.0, 10.0, 10, 10);

  // シェーダプログラムの適用を解除	
  glUseProgram(0);

	//テクスチャ、半透明物体があるとき
	glDepthMask(GL_FALSE); //デプスバッファを書き込み禁止
	glEnable(GL_BLEND);//アルファブレンディングを有効にする
	glBlendFunc(GL_DST_ALPHA,GL_ONE_MINUS_SRC_ALPHA);//色混合係数を決める

	//半透明描画
	drawWave();
	//テクスチャ、半透明物体があるとき
	glDepthMask(GL_TRUE); //デプスバッファの書き込みを許可
	glDisable(GL_BLEND);
	
  //影
  drawShadow();

	drawLight();

  if(flagHelp)
  {
		printf("矢印キーによる光源/投影中心移動 \n");
		printf(" →,←:x軸 \n");
		printf(" ↑,↓:y軸 \n");
		printf(" [Shift]+↑,↓:z軸 \n");
		printf(" 'l'を押した後、光源位置の移動可 \n");
		printf("'w'でワイヤーフレームとソリッドモデル切り替え \n");
		printf("マウス操作で視点変更可 \n");
		printf("  dolly:中央付近を左ボタンクリックで近づき,右ボタンクリックで遠ざかる \n");
		printf("  pan:左横および右横を右ボタンクリックで注視点が左右に変化する \n");
		printf("  tilt:真上および真下を右ボタンクリックで注視点が上下に変化する \n");
		printf("  tumble:左右にドラッグすると視点が左右に変化する \n");
		printf("  crane:上下にドラッグすると視点が上下に変化する \n");
		printf("  zoom:左下を右ボタンクリックでズームイン \n");
		printf("        右下を右ボタンクリックでズームアウト \n");
		printf("[Shift]+'r'でリセット \n");
		printf("[F1]キー:投影マッピングの視野角fovの増減 \n");
		printf("[F2]キー:波の振幅amp \n");
		printf("[F3]キー:波の種類(円形波と平面波)の切り替え \n");
		printf("[F4]キー:円形波の個数切り替え \n");
		flagHelp = false;
  }
  //終了
  glutSwapBuffers();
}
开发者ID:kzfm1024,项目名称:misc,代码行数:99,代码来源:slCaustics.cpp

示例9: ASSERT

// For each Direct3D sampler of either the pixel or vertex stage,
// looks up the corresponding OpenGL texture image unit and texture type,
// and sets the texture and its addressing/filtering state (or NULL when inactive).
// Sampler mapping needs to be up-to-date on the program object before this is called.
gl::Error RendererD3D::applyTextures(const gl::Data &data, gl::SamplerType shaderType,
                                     const FramebufferTextureArray &framebufferTextures, size_t framebufferTextureCount)
{
    ProgramD3D *programD3D = GetImplAs<ProgramD3D>(data.state->getProgram());

    ASSERT(!programD3D->isSamplerMappingDirty());

    unsigned int samplerRange = programD3D->getUsedSamplerRange(shaderType);
    for (unsigned int samplerIndex = 0; samplerIndex < samplerRange; samplerIndex++)
    {
        GLenum textureType = programD3D->getSamplerTextureType(shaderType, samplerIndex);
        GLint textureUnit = programD3D->getSamplerMapping(shaderType, samplerIndex, *data.caps);
        if (textureUnit != -1)
        {
            gl::Texture *texture = data.state->getSamplerTexture(textureUnit, textureType);
            ASSERT(texture);

            gl::Sampler *samplerObject = data.state->getSampler(textureUnit);

            const gl::SamplerState &samplerState =
                samplerObject ? samplerObject->getSamplerState() : texture->getSamplerState();

            // TODO: std::binary_search may become unavailable using older versions of GCC
            if (texture->isSamplerComplete(samplerState, data) &&
                !std::binary_search(framebufferTextures.begin(),
                                    framebufferTextures.begin() + framebufferTextureCount, texture))
            {
                gl::Error error = setSamplerState(shaderType, samplerIndex, texture, samplerState);
                if (error.isError())
                {
                    return error;
                }

                error = setTexture(shaderType, samplerIndex, texture);
                if (error.isError())
                {
                    return error;
                }
            }
            else
            {
                // Texture is not sampler complete or it is in use by the framebuffer.  Bind the incomplete texture.
                gl::Texture *incompleteTexture = getIncompleteTexture(textureType);

                gl::Error error = setSamplerState(shaderType, samplerIndex, incompleteTexture,
                                                  incompleteTexture->getSamplerState());
                if (error.isError())
                {
                    return error;
                }

                error = setTexture(shaderType, samplerIndex, incompleteTexture);
                if (error.isError())
                {
                    return error;
                }
            }
        }
        else
        {
            // No texture bound to this slot even though it is used by the shader, bind a NULL texture
            gl::Error error = setTexture(shaderType, samplerIndex, NULL);
            if (error.isError())
            {
                return error;
            }
        }
    }

    // Set all the remaining textures to NULL
    size_t samplerCount = (shaderType == gl::SAMPLER_PIXEL) ? data.caps->maxTextureImageUnits
                                                            : data.caps->maxVertexTextureImageUnits;
    clearTextures(shaderType, samplerRange, samplerCount);

    return gl::Error(GL_NO_ERROR);
}
开发者ID:lxlpp123,项目名称:angle,代码行数:80,代码来源:RendererD3D.cpp

示例10: getMeshIndexData

void Sprite3D::createNode(NodeData* nodedata, Node* root, const MaterialDatas& matrialdatas, bool singleSprite)
{
    Node* node=nullptr;
    for(const auto& it : nodedata->modelNodeDatas)
    {
        if(it)
        {
            if(it->bones.size() > 0 || singleSprite)
            {
                auto mesh = Mesh::create(nodedata->id, getMeshIndexData(it->subMeshId));
                if(mesh)
                {
                    _meshes.pushBack(mesh);
                    if (_skeleton && it->bones.size())
                    {
                        auto skin = MeshSkin::create(_skeleton, it->bones, it->invBindPose);
                        mesh->setSkin(skin);
                    }
                    mesh->_visibleChanged = std::bind(&Sprite3D::onAABBDirty, this);

                    if (it->matrialId == "" && matrialdatas.materials.size())
                    {
                        const NTextureData* textureData = matrialdatas.materials[0].getTextureData(NTextureData::Usage::Diffuse);
                        mesh->setTexture(textureData->filename);
                    }
                    else
                    {
                        const NMaterialData*  materialData=matrialdatas.getMaterialData(it->matrialId);
                        if(materialData)
                        {
                            const NTextureData* textureData = materialData->getTextureData(NTextureData::Usage::Diffuse);
                            if(textureData)
                            {
                                auto tex = Director::getInstance()->getTextureCache()->addImage(textureData->filename);
                                if(tex)
                                {
                                    Texture2D::TexParams    texParams;
                                    texParams.minFilter = GL_LINEAR;
                                    texParams.magFilter = GL_LINEAR;
                                    texParams.wrapS = textureData->wrapS;
                                    texParams.wrapT = textureData->wrapT;
                                    tex->setTexParameters(texParams);
                                    mesh->setTexture(tex);
                                    mesh->_isTransparent = (materialData->getTextureData(NTextureData::Usage::Transparency) != nullptr);
                                }

                            }
                        }
                    }
                }
            }
            else
            {
                auto sprite = createSprite3DNode(nodedata,it,matrialdatas);
                if (sprite)
                {
                    if(root)
                    {
                        root->addChild(sprite);
                    } 
                }
                node=sprite;
            } 
        }
    }
    if(nodedata->modelNodeDatas.size() ==0 )
    {
        node= Node::create();
        if(node)
        {
            node->setName(nodedata->id);
            node->setAdditionalTransform(&nodedata->transform);
            if(root)
            {
                root->addChild(node);
            } 
        }
    }
    for(const auto& it : nodedata->children)
    {
        createNode(it,node, matrialdatas, singleSprite);
    }
}
开发者ID:TheWindShan,项目名称:HYFish,代码行数:83,代码来源:CCSprite3D.cpp

示例11: setTexture

void Sprite3D::setTexture(const std::string& texFile)
{
    auto tex = Director::getInstance()->getTextureCache()->addImage(texFile);
    setTexture(tex);
}
开发者ID:TheWindShan,项目名称:HYFish,代码行数:5,代码来源:CCSprite3D.cpp

示例12: setTexture

void MenuButton::popUp()
{
	setTexture(upTexture);

}
开发者ID:ata1453,项目名称:tavernSimulator,代码行数:5,代码来源:MenuButton.cpp

示例13: setTexture

void GraphicsDeviceGL_1_3::setShaderResource(TextureHandle handle, u32 nameHash, u32 slot)
{
	setTexture(handle);
}
开发者ID:Mailaender,项目名称:XL-Engine,代码行数:4,代码来源:graphicsDeviceGL_1_3.cpp

示例14: ccp

bool ParticleTraceEmitter::initWithTotalParticles(unsigned int numberOfPartiles)
{
	if (CCParticleSystemQuad::initWithTotalParticles(numberOfPartiles))
	{
		// duration
		m_fDuration = kCCParticleDurationInfinity;

		// Gravity Mode
		this->m_nEmitterMode = kCCParticleModeGravity;

		this->m_ePositionType = kCCPositionTypeFree;

		// Gravity Mode: gravity
		this->modeA.gravity = ccp(0, 0);

		// Gravity Mode: radial acceleration
		this->modeA.radialAccel = 0;
		this->modeA.radialAccelVar = 0;

		// Gravity Mode: speed of particles
		this->modeA.speed = 0;
		this->modeA.speedVar = 0;

		// starting angle
		m_fAngle = 90;
		m_fAngleVar = 0;

		// emitter position
		CCSize winSize = CCDirector::sharedDirector()->getWinSize();
		//this->setPosition(ccp(winSize.width / 2, 60));
		//this->m_tPosVar = ccp(40, 20);

		// life of particles
		m_fLife = 1;
		m_fLifeVar = 0.0f;


		// size, in pixels
		m_fStartSize = 30.0f;
		//m_fStartSizeVar = 54.0f;
		m_fEndSize = kCCParticleStartSizeEqualToEndSize;

		// emits per frame
		m_fEmissionRate = 40.0f;
		//m_uTotalParticles = 50;
		// color of particles
		m_tStartColor.r = 1.0f;
		m_tStartColor.g = 1.0f;
		m_tStartColor.b = 1.0f;
		m_tStartColor.a = 1.0f;
		m_tStartColorVar.r = 0.0f;
		m_tStartColorVar.g = 0.0f;
		m_tStartColorVar.b = 0.0f;
		m_tStartColorVar.a = 0.0f;
		m_tEndColor.r = 1.0f;
		m_tEndColor.g = 1.0f;
		m_tEndColor.b = 1.0f;
		m_tEndColor.a = 0.0f;
		m_tEndColorVar.r = 0.0f;
		m_tEndColorVar.g = 0.0f;
		m_tEndColorVar.b = 0.0f;
		m_tEndColorVar.a = 0.0f;

		setTexture(CCTextureCache::sharedTextureCache()->addImage("./Data/fire.png"));//.pvr");

		// additive
		this->setBlendAdditive(true);
		mLayer->addChild(this);
		return true;
	}
	return false;
}
开发者ID:ECNU-ZR,项目名称:physwf-c-lab,代码行数:72,代码来源:PartileEmitter.cpp

示例15: ccp

bool CCParticleFire::initWithTotalParticles(unsigned int numberOfParticles)
{
    if( CCParticleSystemQuad::initWithTotalParticles(numberOfParticles) )
    {
        // duration
        m_fDuration = kCCParticleDurationInfinity;

        // Gravity Mode
        this->m_nEmitterMode = kCCParticleModeGravity;

        // Gravity Mode: gravity
        this->modeA.gravity = ccp(0,0);

        // Gravity Mode: radial acceleration
        this->modeA.radialAccel = 0;
        this->modeA.radialAccelVar = 0;

        // Gravity Mode: speed of particles
        this->modeA.speed = 60;
        this->modeA.speedVar = 20;        

        // starting angle
        m_fAngle = 90;
        m_fAngleVar = 10;

        // emitter position
        CCSize winSize = CCDirector::sharedDirector()->getWinSize();
        this->setPosition(ccp(winSize.width/2, 60));
        this->m_tPosVar = ccp(40, 20);

        // life of particles
        m_fLife = 3;
        m_fLifeVar = 0.25f;


        // size, in pixels
        m_fStartSize = 54.0f;
        m_fStartSizeVar = 10.0f;
        m_fEndSize = kCCParticleStartSizeEqualToEndSize;

        // emits per frame
        m_fEmissionRate = m_uTotalParticles/m_fLife;

        // color of particles
        m_tStartColor.r = 0.76f;
        m_tStartColor.g = 0.25f;
        m_tStartColor.b = 0.12f;
        m_tStartColor.a = 1.0f;
        m_tStartColorVar.r = 0.0f;
        m_tStartColorVar.g = 0.0f;
        m_tStartColorVar.b = 0.0f;
        m_tStartColorVar.a = 0.0f;
        m_tEndColor.r = 0.0f;
        m_tEndColor.g = 0.0f;
        m_tEndColor.b = 0.0f;
        m_tEndColor.a = 1.0f;
        m_tEndColorVar.r = 0.0f;
        m_tEndColorVar.g = 0.0f;
        m_tEndColorVar.b = 0.0f;
        m_tEndColorVar.a = 0.0f;

        CCTexture2D* pTexture = getDefaultTexture();
        if (pTexture != NULL)
        {
            setTexture(pTexture);
        }
        
        // additive
        this->setBlendAdditive(true);
        return true;
    }
    return false;
}
开发者ID:fordream,项目名称:quick,代码行数:73,代码来源:CCParticleExamples.cpp


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