本文整理汇总了C++中CCTexture2D::setTexParameters方法的典型用法代码示例。如果您正苦于以下问题:C++ CCTexture2D::setTexParameters方法的具体用法?C++ CCTexture2D::setTexParameters怎么用?C++ CCTexture2D::setTexParameters使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCTexture2D
的用法示例。
在下文中一共展示了CCTexture2D::setTexParameters方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: generateTexture
CCTexture2D* Sky::generateTexture()
{
CCRenderTexture* pRenderTexture = CCRenderTexture::create(m_nTextureSize, m_nTextureSize);
pRenderTexture->beginWithClear(0.55f, 0.80f, 0.86f, 1.0f);
//gradient
float alpha = 1.0f;
ccColor4B color1 = {255, 255, 255, 0};
ccColor4B color2 = {255, 255, 255, 255};
CCLayerGradient* pLayerColor = CCLayerGradient::create(color1, color2);
pLayerColor->setContentSize(CCSizeMake(m_nTextureSize, m_nTextureSize));
pLayerColor->setPosition(ccp(0, 0));
pLayerColor->visit();
//noise
CCSprite* pSprite = CCSprite::create("noise.png");
pSprite->setPosition(ccp(m_nTextureSize / 2, m_nTextureSize / 2));
pSprite->setBlendFunc((ccBlendFunc){GL_DST_COLOR, GL_ZERO});
pSprite->setScale(m_nTextureSize / 512.0f);
pSprite->visit();
pRenderTexture->end();
CCTexture2D* pTex = pRenderTexture->getSprite()->getTexture();
ccTexParams params = {GL_NEAREST, GL_NEAREST, GL_REPEAT, GL_REPEAT};
pTex->setTexParameters(¶ms);
return pTex;
}
示例2: generateBackground
void TilemapRender::generateBackground()
{
ostringstream texturePath;
texturePath<<"resources.pak/terrain/";
texturePath<<m_SetID<<"-14.png";
CCRenderTexture* rt = CCRenderTexture::create(64,64);
rt->begin();
CCSprite* tile1 = CCSprite::create(texturePath.str().c_str());
tile1->setAnchorPoint(ccp(0,0));
tile1->setPosition(ccp(0,0));
tile1->visit();
rt->end();
CCTexture2D* texture = rt->getSprite()->getTexture();
ccTexParams tp = {GL_LINEAR, GL_LINEAR, GL_REPEAT, GL_REPEAT};
texture->setTexParameters(&tp);
m_SpriteB->setTexture(texture);
m_SpriteB->setTextureRect(CCRectMake(0, 0, m_MapWidth*64, m_MapHeight*64));
}
示例3: init
// on "init" you need to initialize your instance
bool LevelGameScene::init()
{
if ( !CCLayerColor::initWithColor( ccc4(100, 100, 100, 255) ) )
{
return false;
}
CCSize vs = CCDirector::sharedDirector()->getVisibleSize();
CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();
// Fondo con la textura de madera
ccTexParams tp = { GL_LINEAR, GL_LINEAR, GL_REPEAT, GL_REPEAT};
CCTexture2D* texture = CCTextureCache::sharedTextureCache()->addImage("purty_wood.png");
texture->setTexParameters(&tp);
CCSprite* background = CCSprite::createWithTexture(texture, CCRectMake(0, 0, vs.width, vs.height));
background->setPosition( ccp( vs.width/2, vs.height/2 ) );
this->addChild(background, 1);
CCMenuItem* level1 = CCMenuItemImage::create("btn_level_1.png", "btn_level_1_h.png", this, menu_selector(LevelGameScene::level1Callback));
level1->setPosition(ccp(vs.width/2 - 275, vs.height/2));
CCMenuItem* level2 = CCMenuItemImage::create("btn_level_2.png", "btn_level_2_h.png", this, menu_selector(LevelGameScene::level2Callback));
level2->setPosition(ccp(vs.width/2, vs.height/2));
CCMenuItem* level3 = CCMenuItemImage::create("btn_level_3.png", "btn_level_3_h.png", this, menu_selector(LevelGameScene::level3Callback));
level3->setPosition(ccp(vs.width/2 + 275, vs.height/2));
CCMenu* menu = CCMenu::create(level1, level2, level3, NULL);
menu->setPosition(ccp(0,0));
this->addChild(menu, 5);
this->setTouchEnabled(true);
return true;
}
示例4: init
//.........这里部分代码省略.........
menu->setPosition(ccp(0,0));
// Velocidad
CCString* stringVel = CCString::createWithFormat("%d km/h", (int)_vel);
_labelVel = CCLabelTTF::create(stringVel->getCString(), "fonts/FrancoisOne.ttf", 30, CCSizeMake(140, 50), kCCTextAlignmentCenter);
_labelVel->setColor(ccc3(255,255,255));
_labelVel->setPosition(ccp(vs.width - 72, 50));
// Distancia
CCString* stringDist = CCString::createWithFormat("%d m", (int)_dist);
_labelDist = CCLabelTTF::create(stringDist->getCString(), "fonts/FrancoisOne.ttf", 30, CCSizeMake(140, 50), kCCTextAlignmentCenter);
_labelDist->setColor(ccc3(255,255,255));
_labelDist->setPosition(ccp(72, 50));
// Tiempo
int hs = _time/3600000;
int mins = (_time%3600000)/60000;
int ss = ((_time%3600000)%60000)/1000;
int ms = ((_time%3600000)%60000)%1000;
CCString* stringTime = CCString::createWithFormat("%d:%02d:%03d", mins, ss, ms);
_labelTime = CCLabelTTF::create(stringTime->getCString(), "fonts/FrancoisOne.ttf", 30, CCSizeMake(140, 50), kCCTextAlignmentCenter);
_labelTime->setColor(ccc3(255,255,255));
_labelTime->setPosition(ccp(vs.width - 72, vs.height - 50));
// Click to start
_labelStart = CCLabelTTF::create("Click to Start", "fonts/FrancoisOne.ttf", 50, CCSizeMake(200, 200), kCCTextAlignmentCenter);
_labelStart->setColor(ccc3(255,255,255));
_labelStart->setPosition(ccp(vs.width/2, vs.height/2));
_labelStart->retain();
// Hierba
ccTexParams tp = { GL_LINEAR, GL_LINEAR, GL_REPEAT, GL_REPEAT};
CCTexture2D* texture = CCTextureCache::sharedTextureCache()->addImage("texture_grass2.jpg");
texture->setTexParameters(&tp);
_grass = CCSprite::createWithTexture(texture, CCRectMake(0, 0, vs.width, vs.height + 256));
_grass->setPosition( ccp( vs.width/2, vs.height/2 + 128 ) );
// Carretera
texture = CCTextureCache::sharedTextureCache()->addImage("texture_road2.jpg");
texture->setTexParameters(&tp);
_road = CCSprite::createWithTexture(texture, CCRectMake(0, 0, 512, vs.height + 512));
_road->setPosition( ccp( vs.width/2, vs.height/2 + 256 ) );
// Pianos
texture = CCTextureCache::sharedTextureCache()->addImage("piano.png");
texture->setTexParameters(&tp);
_piano1 = CCSprite::createWithTexture(texture, CCRectMake(0, 0, 64, vs.height + 64));
_piano1->setPosition( ccp(vs.width * 0.15, vs.height / 2 + 32) );
_piano2 = CCSprite::createWithTexture(texture, CCRectMake(0, 0, 64, vs.height + 64));
_piano2->setPosition( ccp(vs.width * 0.85, vs.height / 2 + 32) );
// Coche
_car = CCSprite::create("car_above_blue.png");
_car->setPosition(ccp(vs.width/2, 50));
// Creamos los indicadores de curva
_curvasI = new CCArray;
_curvasD = new CCArray;
for (int i = 1; i <= 5; i++) {
CCString* str_curvaI = CCString::createWithFormat("curva_izq_%d.png", i);
CCString* str_curvaD = CCString::createWithFormat("curva_der_%d.png", i);
CCSprite* curvaI = CCSprite::create(str_curvaI->getCString());
curvaI->setOpacity(0);
curvaI->setPosition(ccp(vs.width/2, vs.height/4*3));
CCSprite* curvaD = CCSprite::create(str_curvaD->getCString());
示例5: init
// on "init" you need to initialize your instance
bool HelloWorld::init() {
//////////////////////////////
// 1. super init first
if (!CCLayer::init()) {
return false;
}
// CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
// CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();
//
// /////////////////////////////
// // 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(origin.x + visibleSize.width - pCloseItem->getContentSize().width/2 ,
// origin.y + pCloseItem->getContentSize().height/2));
//
// // 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
//
// CCLabelTTF* pLabel = CCLabelTTF::create("Hello World", "Arial", 24);
//
// // position the label on the center of the screen
// pLabel->setPosition(ccp(origin.x + visibleSize.width/2,
// origin.y + visibleSize.height - pLabel->getContentSize().height));
//
// // add the label as a child to this layer
// this->addChild(pLabel, 1);
//
// // add "HelloWorld" splash screen"
// CCSprite* pSprite = CCSprite::create("HelloWorld.png");
//
// // position the sprite on the center of the screen
// pSprite->setPosition(
// ccp(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y));
//
// // add the sprite as a child to this layer
// this->addChild(pSprite, 0);
loadTextures();
reset();
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
ccTexParams tp = { GL_LINEAR, GL_LINEAR, GL_REPEAT, GL_CLAMP_TO_EDGE };
CCTexture2D* skyTexture =
CCTextureCache::sharedTextureCache()->textureForKey("sky.png");
skyTexture->setTexParameters(&tp);
_sky = CCSprite::createWithTexture(skyTexture,
CCRectMake(0, 0, winSize.width, 512));
_sky->setPosition(ccp(winSize.width / 2, winSize.height - 256));
this->addChild(_sky, 0);
CCTexture2D* mountainTexture =
CCTextureCache::sharedTextureCache()->textureForKey("horizon.png");
mountainTexture->setTexParameters(&tp);
_mountain = CCSprite::createWithTexture(mountainTexture,
CCRectMake(0, 0, winSize.width, 512));
_mountain->setPosition(ccp(winSize.width / 2, 0));
this->addChild(_mountain, 0);
CCTexture2D* forestTexture =
CCTextureCache::sharedTextureCache()->textureForKey(
"background.png");
forestTexture->setTexParameters(&tp);
_forest2 = Forest::create();
_forest2->setForestTexture(forestTexture);
this->addChild(_forest2, 0);
_forest = Forest::create();
_forest->setForestTexture(forestTexture);
this->addChild(_forest, 0);
CCTexture2D* pathTexture =
CCTextureCache::sharedTextureCache()->textureForKey("path.png");
pathTexture->setTexParameters(&tp);
_path = Path::create();
_path->setPathTexture(pathTexture);
this->addChild(_path, 0);
// CCLOG("begin add shadow");
// CCTexture2D* shadowTexture =
// CCTextureCache::sharedTextureCache()->textureForKey("shadow.png");
// _shadow = Shadow::create();
// _shadow->setShadowTexture(shadowTexture);
//.........这里部分代码省略.........
示例6: init
// on "init" you need to initialize your instance
bool GameScene::init()
{
if ( !CCLayer::init() )
{
return false;
}
CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();
// Fondo con la textura de madera
ccTexParams tp = { GL_LINEAR, GL_LINEAR, GL_REPEAT, GL_REPEAT};
CCTexture2D* texture = CCTextureCache::sharedTextureCache()->addImage("purty_wood.png");
texture->setTexParameters(&tp);
CCSprite* background = CCSprite::createWithTexture(texture, CCRectMake(0, 0, visibleSize.width, visibleSize.height));
background->setPosition( ccp( visibleSize.width/2, visibleSize.height/2 ) );
this->addChild(background, 1);
CCSprite* con_smile = CCSprite::create("con_wait.png", CCRectMake(0,0,64,64) );
con_smile->setPosition( ccp(visibleSize.width - 64, visibleSize.height - 64) );
this->addChild(con_smile, 2);
int aux_nleds = GameManager::sharedGameManager()->getNLeds();
bool connected = GameManager::sharedGameManager()->getConnected();
CCMenuItem *btn_clear = CCMenuItemImage::create("btn_clear.png", "btn_clear_h.png", this, menu_selector(GameScene::menuClearCallback));
btn_clear->setPosition(ccp(visibleSize.width/2, visibleSize.height - 60));
CCMenuItem *button_back = CCMenuItemImage::create("btn_volver.png", "btn_volver_h.png", this, menu_selector(GameScene::menuBackCallback));
button_back->setPosition(ccp(origin.x + 105, visibleSize.height - 60));
CCMenu* menu;
if (connected) {
con_smile->setTexture(CCTextureCache::sharedTextureCache()->addImage("con_ok.png"));
CCMenuItem *button_send = CCMenuItemImage::create("btn_enviar.png", "btn_enviar_h.png", this, menu_selector(GameScene::menuSendCallback));
button_send->setPosition(ccp(visibleSize.width - 105, origin.y + 60));
menu = CCMenu::create(button_send, button_back, btn_clear, NULL);
} else {
menu = CCMenu::create(button_back, btn_clear, NULL);
}
menu->setPosition(ccp(0,0));
this->addChild(menu, 5);
scrollView = CCScrollView::create(CCSizeMake(visibleSize.width, visibleSize.height/3));
scrollView->setContentSize(CCSizeMake(140*aux_nleds, visibleSize.height/3));
scrollView->setDirection(kCCScrollViewDirectionHorizontal);
scrollView->setPosition(ccp(10, visibleSize.height/3));
scrollView->setTouchEnabled(true);
this->addChild(scrollView, 5);
menu_leds = CCMenu::create();
menu_leds->setPosition(ccp(0,0));
scrollView->addChild(menu_leds, 5);
_labels = CCArray::create();
_labels->retain();
for (int i=0; i<aux_nleds; i++) {
CCMenuItem *item_led = CCMenuItemImage::create("LED3.png", "LED3.png", this, menu_selector(GameScene::itemLedCallback));
//CCSprite *sprite = CCSprite::create( "LED3.png", CCRectMake(0,0,120,120) );
item_led->setAnchorPoint(CCPointZero);
item_led->setPosition(ccp(140*i + 10, 0));
item_led->setTag(i);
menu_leds->addChild(item_led);
CCString* i_str = CCString::createWithFormat("%d", i+1);
CCLabelTTF *label = CCLabelTTF::create(i_str->getCString(), "Helvetica", 25, CCSizeMake(50, 30), kCCTextAlignmentCenter);
label->setPosition(ccp(140*i + 45, 130));
label->setAnchorPoint(CCPointZero);
label->setTag(123);
label->setColor(ccc3(0,0,255));
label->setHorizontalAlignment(kCCTextAlignmentCenter);
scrollView->addChild(label);
_labels->insertObject(label, i);
}
_palette = CCSprite::create( "256colour.png", CCRectMake(0,0,512,128) );
_palette->setPosition( ccp( origin.x + 256, origin.y + 64 ) );
this->addChild(_palette, 5);
_ledsSelected = CCArray::create();
_ledsSelected->retain();
this->setTouchEnabled(true);
return true;
}