本文整理汇总了C++中CCTexture2D::setAliasTexParameters方法的典型用法代码示例。如果您正苦于以下问题:C++ CCTexture2D::setAliasTexParameters方法的具体用法?C++ CCTexture2D::setAliasTexParameters怎么用?C++ CCTexture2D::setAliasTexParameters使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCTexture2D
的用法示例。
在下文中一共展示了CCTexture2D::setAliasTexParameters方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: schedule
FMMainScene::FMMainScene()
:m_currentScene(kLoadingNode)
{
//load textures for test
NEAnimManager::sharedManager()->loadSpriteframesFromFile(CCString::create("Elements.plist"));
NEAnimManager::sharedManager()->loadSpriteframesFromFile(CCString::create("Map.plist"));
CCTexture2D * tex = CCTextureCache::sharedTextureCache()->textureForKey("Map.pvr.ccz");
tex->setAliasTexParameters();
CC_PROFILER_START("GameNode Init");
m_energyManager = FMEnergyManager::manager();
schedule(schedule_selector(FMMainScene::update), 1.f);
m_ui = GAMEUI_Scene::uiSystem();
addChild(m_ui, 1000);
m_worldMap = FMWorldMapNode::create();
m_worldMap->retain();
m_game = FMGameNode::create();
m_game->retain();
FMStatusbar * statusbar = (FMStatusbar *)FMDataManager::sharedManager()->getUI(kUI_Statusbar);
m_statusbar = statusbar;
addChild(statusbar, 2000);
//tutorial
FMTutorial * tut = FMTutorial::tut();
m_tutorial = tut;
m_tutorial->setVisible(false);
addChild(tut, 3000);
CC_PROFILER_STOP("GameNode Init");
CC_PROFILER_DISPLAY_TIMERS();
}
示例2: start
void GameScene::start(float dt)
{
bool autoPlay = true;
// apply loaded image
for(auto it = mImageDictionary.begin(); it != mImageDictionary.end(); it++)
{
CCTexture2D* texture = new CCTexture2D();
if(false == texture->initWithImage(it->second))
{
delete texture;
continue;
}
mBgaDictionary[it->first] = texture;
}
for(auto it = mBmsDocument.channel().begin(); it != mBmsDocument.channel().end(); it++)
{
const std::string& channel = it->first;
if(channel.find("01") != std::string::npos)
{
mChannelPlayers[channel] = new WaveChannelPlayer(it->second, mWavDictionary);
}
else if(channel.find("02") != std::string::npos)
{
//mChannelPlayers[channel] = new BarScaleChannelPlayer(it->second);
}
else if(channel.find("03") != std::string::npos)
{
mChannelPlayers[channel] = new BpmChannelPlayer(it->second);
}
else
{
int iChannel = base36ToInt(channel.c_str());
if(base36ToInt("10") < iChannel && iChannel < base36ToInt("70") && channel[1] != '0'/*exclude 20, 30, 40, ...*/)
{
int mappedKey = -1;
for(int i=0; i<sizeof(keyChannelMap)/sizeof(keyChannelMap[0]); i++)
{
if(channel == keyChannelMap[i])
{
mappedKey = i;
break;
}
}
if(mappedKey < 0)
{
mChannelPlayers[channel] = new WaveChannelPlayer(it->second, mWavDictionary);
}
else
{
mChannelPlayers[channel] = new PlayChannelPlayer(it->second, mWavDictionary, Key::MappedKey(mappedKey), autoPlay);
}
}
else if(
base36ToInt(ChannelType::BGA_BASE) == iChannel ||
base36ToInt(ChannelType::BGA_LAYER) == iChannel ||
base36ToInt(ChannelType::BGA_LAYER2) == iChannel
)
{
BgaChannelPlayer* bgaPlayer = new BgaChannelPlayer(it->second, mBgaDictionary, base36ToInt(ChannelType::BGA_POOR) == iChannel);
mChannelPlayers[channel] = bgaPlayer;
bgaPlayer->getSprite()->setContentSize(Size(640, 480));
bgaPlayer->getSprite()->setPosition(Point(640, 480));
addChild(bgaPlayer->getSprite());
}
}
}
{//panel
// load skin
CCTexture2D* skinTexture = CCTextureCache::sharedTextureCache()->addImage(Panel::SKIN_PATH);
// no antialias
skinTexture->setAliasTexParameters();
CCNode* panel = CCNode::create();
addChild(panel);
Panel* frontPanel = new FrontPanel;
Panel* backPanel = new BackPanel(mChannelPlayers);
Panel* controlPanel = new ControlPanel;
panel->addChild(backPanel);
panel->addChild(frontPanel);
panel->addChild(controlPanel);
// fit panel to screen
panel->setScale(CCDirector::sharedDirector()->getOpenGLView()->getDesignResolutionSize().height / 480);
}
mCurrentBpm = mBmsDocument.header().getBpm();
//끝낼 마디 설정
mEndPosition = 0;
for(auto it = mBmsDocument.channel().begin(); it != mBmsDocument.channel().end(); it++)
{
if(it->second->endPosition() > mEndPosition)
mEndPosition = it->second->endPosition();
}
//.........这里部分代码省略.........
示例3: ResHandle
void XSpriteBatchNode::ResHandle( long lParam )
{
XFUNC_START();
do
{
const char* szPath = NULL;
XResType* pResType = XResLoader::Instance().GetResByID(lParam);
if (!pResType)
{
break;
}
CCTexture2D* pTex;
if (XResType::ePng == pResType->GetType())
{
XResPNG* pRes = dynamic_cast<XResPNG*>(pResType);
if (!pRes)
{
break;
}
XTexture2D* &pCTex = pRes->m_pTexture;
if (!pCTex)
{
break;
}
if (pRes->m_pImage)
{
bool bRes = XTextureCache::Instance().InitTexture(pRes->m_szPath, pRes->m_pImage, pCTex);
if (!bRes)
{
break;
}
// Òѽ«Í¼Æ¬×ª»¯ÎªÌùͼ£¬É¾³ýͼƬ£¬ÊÍ·ÅÄÚ´æ¡£
delete pRes->m_pImage;
pRes->m_pImage = NULL;
}
pTex = pCTex;
szPath = pRes->m_szPath;
}
else
{
break;
//// ѹËõÎÆÀí
//XResCompressed* pRes = dynamic_cast<XResCompressed*>(pResType);
//if (!pRes)
//{
// break;
//}
//XTexture2D* &pXTex = pRes->m_pTexture;
//if (!pXTex)
//{
// break;
//}
//if (!pRes->m_byTexInited)
//{
// bool bRes = XTextureCache::Instance().InitTexture(pRes->m_szPath, pXTex, pRes->m_pTexAlpha);
// if (!bRes)
// {
// break;
// }
// pRes->m_byTexInited = 0xFF;
//}
//if (pRes->m_pTexAlpha)
//{
// m_pTexKtxAlpha = pRes->m_pTexAlpha;
// m_pTexKtxAlpha->retain();
// m_pShaderKTX = XShader::GetShader(this, XShader::eETC);
//}
//pTex = pXTex;
//szPath = pRes->m_szPath;
}
if(_byAntiAlias)
pTex->setAntiAliasTexParameters();
else
pTex->setAliasTexParameters();
// ´´½¨¾«Áé
XSBNChildInfo* pHead = _stChildren._pHead;
XSBNChildInfo* pUsed;
int nPos = 0;
while(pHead)
{
pUsed = pHead;
pHead = pHead->_pNext;
XSprite* pSprite = XSprite::createWithTexture(pTex, pUsed->stRect, _byAntiAlias);
if (!pSprite)
{
CCLOG("XSprite::createWithTexture failed!");
continue;
}
if (pUsed->byFlipX)
{
pSprite->setFlipX(true);
}
pSprite->setAnchorPoint(ccp(0.f, 0.f));
pSprite->setPosition(ccp(pUsed->fPosX, pUsed->fPosY));
pSprite->setScaleY(_fChildrenScaleY);
CCSpriteBatchNode::addChild(pSprite, pSprite->getZOrder(), nPos++);
XMP_RELEASE(XSBNChildInfo, pUsed);
}
_stChildren.Clear();
_bResLoaded = true;
//.........这里部分代码省略.........
示例4: initWithImageInfo
bool CCMeshImage::initWithImageInfo(CCMeshImageInfo* info)
{
bool error_found = false;
for (std::vector<CCMeshSliceInfo>::iterator slice = info->slices.begin();
slice != info->slices.end(); slice++)
{
CCTextureAtlas* atlas = NULL;
CCTextureAtlasMap::iterator atlas_it = m_atlas_map.find(slice->texture_id);
if (atlas_it == m_atlas_map.end())
{
std::string tex_filename = info->id2tex[slice->texture_id];
CCTexture2D* texture = CCTextureCache::sharedTextureCache()->addImage(tex_filename.c_str());
if (!texture)
{
error_found = true;
break;
}
texture->setAliasTexParameters();
atlas = new CCTextureAtlas();
atlas->initWithTexture(texture, 15);
m_atlas_map[slice->texture_id] = atlas;
}
else
{
atlas = atlas_it->second;
}
if (atlas->getTotalQuads() == atlas->getCapacity())
{
atlas->resizeCapacity(atlas->getCapacity() * 1.5f + 1);
}
CCSize tex_size = atlas->getTexture()->getContentSize();
float left = slice->texture_pos.x / tex_size.width;
float right = left + slice->size.width / tex_size.width;
float top = slice->texture_pos.y / tex_size.height;
float bottom = top + slice->size.height / tex_size.height;
float ele_pos_left = slice->image_pos.x / info->scale_ratio;
float ele_pos_top = (slice->image_pos.y + slice->size.height) / info->scale_ratio;
float ele_width = slice->size.width / info->scale_ratio;
float ele_height = slice->size.height / info->scale_ratio;
ccV3F_C4B_T2F_Quad quad;
if (slice->rotated)
{
quad.bl.texCoords.u = left;
quad.bl.texCoords.v = top;
quad.br.texCoords.u = left;
quad.br.texCoords.v = bottom;
quad.tl.texCoords.u = right;
quad.tl.texCoords.v = top;
quad.tr.texCoords.u = right;
quad.tr.texCoords.v = bottom;
}
else
{
quad.bl.texCoords.u = left;
quad.bl.texCoords.v = bottom;
quad.br.texCoords.u = right;
quad.br.texCoords.v = bottom;
quad.tl.texCoords.u = left;
quad.tl.texCoords.v = top;
quad.tr.texCoords.u = right;
quad.tr.texCoords.v = top;
}
quad.bl.vertices.x = (float) (ele_pos_left);
quad.bl.vertices.y = ele_pos_top - ele_height;
quad.bl.vertices.z = 0.0f;
quad.br.vertices.x = (float)(ele_pos_left + ele_width);
quad.br.vertices.y = ele_pos_top - ele_height;
quad.br.vertices.z = 0.0f;
quad.tl.vertices.x = (float)(ele_pos_left);
quad.tl.vertices.y = ele_pos_top;
quad.tl.vertices.z = 0.0f;
quad.tr.vertices.x = (float)(ele_pos_left + ele_width);
quad.tr.vertices.y = ele_pos_top;
quad.tr.vertices.z = 0.0f;
atlas->updateQuad(&quad, atlas->getTotalQuads());
}
if (!error_found)
{
m_name = new CCString(info->name);
setAnchorPoint(ccp(0, 0));
setContentSize(CCSize(info->size.width / info->scale_ratio, info->size.height / info->scale_ratio));
// shader stuff
setShaderProgram(CCShaderCache::sharedShaderCache()->programForKey(kCCShader_PositionTexture_uColor));
//m_nUniformColor = glGetUniformLocation( getShaderProgram()->getProgram(), "u_color");
}
return !error_found;
}