本文整理汇总了C++中CCTexture2D::getPixelsHigh方法的典型用法代码示例。如果您正苦于以下问题:C++ CCTexture2D::getPixelsHigh方法的具体用法?C++ CCTexture2D::getPixelsHigh怎么用?C++ CCTexture2D::getPixelsHigh使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCTexture2D
的用法示例。
在下文中一共展示了CCTexture2D::getPixelsHigh方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetTexture
void SuperAnimSprite::SetTexture(CCTexture2D *theTexture, CCRect theTextureRect)
{
if (theTexture == NULL)
{
return;
}
if (mTexture != NULL)
{
mTexture->release();
mTexture = NULL;
}
// retain this texture in case removed by removeUnusedTextures();
theTexture->retain();
mTexture = theTexture;
// Set Texture coordinates
CCRect theTexturePixelRect = CC_RECT_POINTS_TO_PIXELS(theTextureRect);
float aTextureWidth = (float)mTexture->getPixelsWide();
float aTextureHeight = (float)mTexture->getPixelsHigh();
float aLeft, aRight, aTop, aBottom;
aLeft = theTexturePixelRect.origin.x / aTextureWidth;
aRight = (theTexturePixelRect.origin.x + theTexturePixelRect.size.width) / aTextureWidth;
aTop = theTexturePixelRect.origin.y / aTextureHeight;
aBottom = (theTexturePixelRect.origin.y + theTexturePixelRect.size.height) / aTextureHeight;
mQuad.bl.texCoords.u = aLeft;
mQuad.bl.texCoords.v = aBottom;
mQuad.br.texCoords.u = aRight;
mQuad.br.texCoords.v = aBottom;
mQuad.tl.texCoords.u = aLeft;
mQuad.tl.texCoords.v = aTop;
mQuad.tr.texCoords.u = aRight;
mQuad.tr.texCoords.v = aTop;
// Set position
//float x1 = 0;
//float y1 = 0;
//float x2 = x1 + theTextureRect.size.width;
//float y2 = y1 + theTextureRect.size.height;
float x1 = theTexturePixelRect.size.width * -0.5f;
float y1 = theTexturePixelRect.size.height * -0.5f;
float x2 = theTexturePixelRect.size.width * 0.5f;
float y2 = theTexturePixelRect.size.height * 0.5f;
mQuad.bl.vertices = vertex3(x1, y1, 0);
mQuad.br.vertices = vertex3(x2, y1, 0);
mQuad.tl.vertices = vertex3(x1, y2, 0);
mQuad.tr.vertices = vertex3(x2, y2, 0);
// Set color
ccColor4B aDefaultColor = {255, 255, 255, 255};
mQuad.bl.colors = aDefaultColor;
mQuad.br.colors = aDefaultColor;
mQuad.tl.colors = aDefaultColor;
mQuad.tr.colors = aDefaultColor;
}
示例2: CCImage
AnimatedCell::AnimatedCell(int cellX, int cellY, int spacing, const char* pngFileName) {
this->setSpace(spacing);
this->setPngFileName(pngFileName);
animation_ = CCAnimation::create();
CCImage* image = new CCImage();
image->initWithImageFile(pngFileName);
CCTexture2D* texture = new CCTexture2D();
texture->initWithImage(image);
oneWidth_ = texture->getPixelsWide() / spacing;
oneHeight_ = texture->getPixelsHigh();
for (int i=0; i<spacing; i++) {
animation_->addSpriteFrameWithTexture(texture,
CCRectMake(i*oneWidth_, 0, oneWidth_, oneHeight_));
}
CCSpriteFrame* frm = ((CCAnimationFrame*)(animation_->getFrames()->objectAtIndex(0)))->getSpriteFrame();
this->initWithSpriteFrame(frm);
animation_->setDelayPerUnit(0.5f);
animate_ = CCRepeatForever::create(CCAnimate::create(animation_));
setCell(cellX, cellY);
}
示例3: _spAtlasPage_createTexture
void _spAtlasPage_createTexture (spAtlasPage* self, const char* path) {
CCTexture2D* texture = CCTextureCache::sharedTextureCache()->addImage(path);
texture->retain();
self->rendererObject = texture;
self->width = texture->getPixelsWide();
self->height = texture->getPixelsHigh();
}
示例4: updateAtlasValues
//CCLabelAtlas - Atlas generation
void CCLabelAtlas::updateAtlasValues()
{
unsigned int n = m_sString.length();
ccV3F_C4B_T2F_Quad quad;
const unsigned char *s = (unsigned char*)m_sString.c_str();
CCTexture2D *texture = m_pTextureAtlas->getTexture();
float textureWide = (float) texture->getPixelsWide();
float textureHigh = (float) texture->getPixelsHigh();
for(unsigned int i = 0; i < n; i++) {
unsigned char a = s[i] - m_cMapStartChar;
float row = (float) (a % m_uItemsPerRow);
float col = (float) (a / m_uItemsPerRow);
#if CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL
// Issue #938. Don't use texStepX & texStepY
float left = (2 * row * m_uItemWidth + 1) / (2 * textureWide);
float right = left + (m_uItemWidth * 2 - 2) / (2 * textureWide);
float top = (2 * col * m_uItemHeight + 1) / (2 * textureHigh);
float bottom = top + (m_uItemHeight * 2 - 2) / (2 * textureHigh);
#else
float left = row * m_uItemWidth / textureWide;
float right = left + m_uItemWidth / textureWide;
float top = col * m_uItemHeight / textureHigh;
float bottom = top + m_uItemHeight / textureHigh;
#endif // ! CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL
quad.tl.texCoords.u = left;
quad.tl.texCoords.v = top;
quad.tr.texCoords.u = right;
quad.tr.texCoords.v = top;
quad.bl.texCoords.u = left;
quad.bl.texCoords.v = bottom;
quad.br.texCoords.u = right;
quad.br.texCoords.v = bottom;
float scale = CC_CONTENT_SCALE_FACTOR();
quad.bl.vertices.x = scale * (i * m_uItemWidth);
quad.bl.vertices.y = 0;
quad.bl.vertices.z = 0.0f;
quad.br.vertices.x = scale * (i * m_uItemWidth + m_uItemWidth);
quad.br.vertices.y = 0;
quad.br.vertices.z = 0.0f;
quad.tl.vertices.x = scale * (i * m_uItemWidth);
quad.tl.vertices.y = scale * (m_uItemHeight);
quad.tl.vertices.z = 0.0f;
quad.tr.vertices.x = scale * (i * m_uItemWidth + m_uItemWidth);
quad.tr.vertices.y = scale * (m_uItemHeight);
quad.tr.vertices.z = 0.0f;
m_pTextureAtlas->updateQuad(&quad, i);
}
}
示例5: caculateTileTableTextureCoord
void CScutAniGroup::caculateTileTableTextureCoord()
{
CCTexture2D* pTexture = NULL;
double factor = 1.0;
for (vec_tile_table_it it = this->m_vTileTable.begin(); it != this->m_vTileTable.end(); it++)
{
ScutTileTable& tt = *it;
assert(tt.imgIndex > -1 && tt.imgIndex < m_vTexture.size());
if (!(tt.imgIndex > -1 && tt.imgIndex < m_vTexture.size()))
{
continue;
}
pTexture = this->m_vTexture[tt.imgIndex].pTex;
assert(pTexture);
if (!pTexture)
{
continue;
}
factor = this->m_vTexture[tt.imgIndex].dFactor;
tt.clip.origin.x *= factor;
tt.clip.origin.y *= factor;
tt.clip.size.width *= factor;
tt.clip.size.height *= factor;
int uPixelsWidth = pTexture->getPixelsWide();
int uPixelsHeight = pTexture->getPixelsHigh();
assert((tt.clip.origin.x + tt.clip.size.width) <= uPixelsWidth + 5);
assert((tt.clip.origin.y + tt.clip.size.height) <= uPixelsHeight + 5);
GLfloat fMinS = max(tt.clip.origin.x / uPixelsWidth, 0);
GLfloat fMinT = max(tt.clip.origin.y / uPixelsHeight, 0);
GLfloat fMaxS = min((tt.clip.origin.x + tt.clip.size.width) / uPixelsWidth, 1);
GLfloat fMaxT = min((tt.clip.origin.y + tt.clip.size.height) / uPixelsHeight, 1);
tt.texCoord[0] = fMinS;
tt.texCoord[1] = fMaxT;
tt.texCoord[2] = fMaxS;
tt.texCoord[3] = fMaxT;
tt.texCoord[4] = fMinS;
tt.texCoord[5] = fMinT;
tt.texCoord[6] = fMaxS;
tt.texCoord[7] = fMinT;
}
}
示例6: spriteWithFile
Player* Player::spriteWithFile(const char *pszFileName, int columns, int rows)
{
// CCSpriteFrame *frame = cacher->spriteFrameByName( pszFileName);
CCTexture2D *texture = CCTextureCache::sharedTextureCache()->addImage(pszFileName);
CCArray* aFrames = CCArray::createWithCapacity(columns * rows);
float textureWidth = texture->getPixelsWide();
float textureHeight = texture->getPixelsHigh();
float frameWidth = textureWidth / columns;
float frameHeight = textureHeight / rows;
for (int c = 0; c < columns; c++)
{
for (int r = 0; r < rows; r++)
{
CCSpriteFrame *frame0 = CCSpriteFrame::createWithTexture(texture, CCRectMake((c*frameWidth), (r*frameHeight), 100, 65));
aFrames->addObject(frame0);
}
}
CCAnimation *animation = CCAnimation::createWithSpriteFrames(aFrames, 0.2f);
CCAnimate *animate = CCAnimate::create(animation);
CCActionInterval* seq = (CCActionInterval*)(CCSequence::create( animate, animate->copy()->autorelease(), CCFlipX::create(false), NULL) );
Player *pobSprite = new Player();
if (pobSprite && pobSprite->initWithSpriteFrame((CCSpriteFrame*) aFrames->objectAtIndex(0)))
{
pobSprite->scheduleUpdate();
pobSprite->autorelease();
pobSprite->setForwardMarch(false);
pobSprite->setMightAsWellJump(false);
pobSprite->setBackwardMarch(false);
pobSprite->runAction(CCRepeatForever::create( seq ) );
// pobSprite->setAnimFrames( aFrames);
// pobSprite->setCurrentFrame(0);
return pobSprite;
}
CC_SAFE_DELETE(pobSprite);
return NULL;
}
示例7: GetTextSize
CCSize CCtrlEdit::GetTextSize(const char * text)
{
CCSize textSize(0.0f,0.0f);
if (NULL == text)
{
return textSize;
}
do
{
CCTexture2D *tex = new CCTexture2D();
CC_BREAK_IF(!tex);
float fContentScaleFactor= CCDirector::sharedDirector()->getContentScaleFactor();
bool bRet = tex->initWithString( text,
m_strFontName.c_str(),
m_nFontSize * fContentScaleFactor,
CCSizeZero,
m_pTextField->getHorizontalAlignment(),
m_pTextField->getVerticalAlignment());
if (bRet)
{
float fOffsetX = tex->getPixelsWide();
fOffsetX /= fContentScaleFactor;
textSize.width += fOffsetX;
float fOffsetY = tex->getPixelsHigh();
fOffsetY /= fContentScaleFactor;
textSize.height += fOffsetY;
}
tex->release();
}while(false);
return textSize;
}
示例8: BeginContact
void HSContacListener::BeginContact( b2Contact* contact )
{
bool touch = contact->IsTouching();
if (touch)
{
b2Body* bodyA = contact->GetFixtureA()->GetBody();
b2Body* bodyB = contact->GetFixtureB()->GetBody();
HSBalloonSprite* spriteA = (HSBalloonSprite*)bodyA->GetUserData();
HSBalloonSprite* spriteB = (HSBalloonSprite*)bodyB->GetUserData();
if (spriteA != NULL && spriteB != NULL)
{
if (bodyA->GetType() == b2_dynamicBody && bodyB->GetType() == b2_dynamicBody)
{
CCPoint pointA = spriteA->getPosition();
CCPoint pointB = spriteB->getPosition();
CCTexture2D* texture = spriteA->getTexture();
float w = texture->getPixelsWide();
float h = texture->getPixelsHigh();
float minY = -(h / 2.f);
CCRect areaA = CCRectMake(pointA.x - w / 2.f,pointA.y - h / 2.f,w,h);
CCRect areaB = CCRectMake(pointB.x - w / 2.f,pointB.y - h / 2.f,w,h);
if (areaA.intersectsRect(areaB) && pointA.y < minY && pointB.y < minY)
{
//spriteA->setVisible(false);
//spriteA->SetIsLiester(true);
spriteA->getB2Body()->ApplyForceToCenter(b2Vec2(0,0.5f));
//spriteA->setColor(ccc3(255,0,0));
//spriteB->setColor(ccc3(255,255,0));
}
}
}
}
}
示例9: updateAtlasValues
void CCRichAtlas::updateAtlasValues()
{
if ( !m_dirty )
{
return;
}
m_dirty = false;
if ( m_pTextureAtlas->getCapacity() < getQuadsToDraw() )
{
m_pTextureAtlas->resizeCapacity( getQuadsToDraw() );
}
ccV3F_C4B_T2F_Quad quad;
CCTexture2D *texture = m_pTextureAtlas->getTexture();
float textureWide = (float) texture->getPixelsWide();
float textureHigh = (float) texture->getPixelsHigh();
int i = 0;
for(std::list<IRichElement*>::iterator it = m_elements.begin();
it != m_elements.end(); it++, i++) {
IRichElement* ele = *it;
RTexture* rtex = ele->getTexture();
#if CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL
float left = (rtex->rect.pos.x + 0.5f)/textureWide;
float right = left + (rtex->rect.size.w - 1.0f)/textureWide;
float top = (rtex->rect.pos.y + 0.5f)/textureHigh;
float bottom = top + (rtex->rect.size.h - 1.0f)/textureHigh;
float ele_pos_left = ele->getGlobalPosition().x;
float ele_pos_top = ele->getGlobalPosition().y;
float ele_width = rtex->rect.size.w /*+ 1.0f*/;
float ele_height = rtex->rect.size.h /*+ 1.0f*/;
#else
float left = rtex->rect.pos.x/textureWide;
float right = left + rtex->rect.size.w/textureWide;
float top = rtex->rect.pos.y/textureHigh;
float bottom = top + rtex->rect.size.h/textureHigh;
float ele_pos_left = ele->getGlobalPosition().x;
float ele_pos_top = ele->getGlobalPosition().y;
float ele_width = rtex->rect.size.w;
float ele_height = rtex->rect.size.h;
#endif // ! CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL
quad.tl.texCoords.u = left;
quad.tl.texCoords.v = top;
quad.tr.texCoords.u = right;
quad.tr.texCoords.v = top;
quad.bl.texCoords.u = left;
quad.bl.texCoords.v = bottom;
quad.br.texCoords.u = right;
quad.br.texCoords.v = bottom;
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;
ccColor4B c = { _displayedColor.r, _displayedColor.g, _displayedColor.b, _displayedOpacity };
quad.tl.colors = c;
quad.tr.colors = c;
quad.bl.colors = c;
quad.br.colors = c;
m_pTextureAtlas->updateQuad(&quad, i);
}
}
示例10: setTextureCoords
void CCSprite::setTextureCoords(CCRect rect)
{
rect = CC_RECT_POINTS_TO_PIXELS(rect);
CCTexture2D *tex = m_pobBatchNode ? m_pobTextureAtlas->getTexture() : m_pobTexture;
if (! tex)
{
return;
}
float atlasWidth = (float)tex->getPixelsWide();
float atlasHeight = (float)tex->getPixelsHigh();
float left, right, top, bottom;
if (m_bRectRotated)
{
#if CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL
left = (2*rect.origin.x+1)/(2*atlasWidth);
right = left+(rect.size.height*2-2)/(2*atlasWidth);
top = (2*rect.origin.y+1)/(2*atlasHeight);
bottom = top+(rect.size.width*2-2)/(2*atlasHeight);
#else
left = rect.origin.x/atlasWidth;
right = (rect.origin.x+rect.size.height) / atlasWidth;
top = rect.origin.y/atlasHeight;
bottom = (rect.origin.y+rect.size.width) / atlasHeight;
#endif // CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL
if (m_bFlipX)
{
CC_SWAP(top, bottom, float);
}
if (m_bFlipY)
{
CC_SWAP(left, right, float);
}
m_sQuad.bl.texCoords.u = left;
m_sQuad.bl.texCoords.v = top;
m_sQuad.br.texCoords.u = left;
m_sQuad.br.texCoords.v = bottom;
m_sQuad.tl.texCoords.u = right;
m_sQuad.tl.texCoords.v = top;
m_sQuad.tr.texCoords.u = right;
m_sQuad.tr.texCoords.v = bottom;
}
else
{
#if CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL
left = (2*rect.origin.x+1)/(2*atlasWidth);
right = left + (rect.size.width*2-2)/(2*atlasWidth);
top = (2*rect.origin.y+1)/(2*atlasHeight);
bottom = top + (rect.size.height*2-2)/(2*atlasHeight);
#else
left = rect.origin.x/atlasWidth;
right = (rect.origin.x + rect.size.width) / atlasWidth;
top = rect.origin.y/atlasHeight;
bottom = (rect.origin.y + rect.size.height) / atlasHeight;
#endif // ! CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL
if(m_bFlipX)
{
CC_SWAP(left,right,float);
}
if(m_bFlipY)
{
CC_SWAP(top,bottom,float);
}
m_sQuad.bl.texCoords.u = left;
m_sQuad.bl.texCoords.v = bottom;
m_sQuad.br.texCoords.u = right;
m_sQuad.br.texCoords.v = bottom;
m_sQuad.tl.texCoords.u = left;
m_sQuad.tl.texCoords.v = top;
m_sQuad.tr.texCoords.u = right;
m_sQuad.tr.texCoords.v = top;
}
}
示例11: Load
void HSGameShopLayer::Load()
{
m_p_backgournd = CCSprite::create("Image/main/shop/BEIJING.png");
m_p_backgournd->setPosition(HSBase::GetScreenCentre());
HSTool::SetNodeFilldScreen(m_p_backgournd);
this->addChild(m_p_backgournd);
m_p_foregroundLayer = CCLayer::create();
HSTool::SetLayerScale(m_p_foregroundLayer);
this->addChild(m_p_foregroundLayer);
HSReadUI::ShareReadUI()->ReadUI("Image/main/shop/shop.data","Image/main/shop/",m_p_foregroundLayer);
HS_SET_MENU_TARGET("UI_sc_fh_01",this,HSGameShopLayer::CallReturn);
HSCCSprite* gameGoldFrame = HS_FIND_UI_PANEL_SPRITE("UI_sc_jinbitoumingdi","Jinbidiandikuang");
CCSize gameGoldFrameSize = gameGoldFrame->getContentSize();
CCTexture2D* pMoneyTexture = CCTextureCache::sharedTextureCache()->addImage("Image/moneyNumber.png");
m_p_shop_money = CCLabelAtlas::create(CCString::createWithFormat("%d",HS_GAME_CACHE()->GetGold())->getCString(),"Image/moneyNumber.png",pMoneyTexture->getPixelsWide() / 11,pMoneyTexture->getPixelsHigh(),'0');
m_p_shop_money->setAnchorPoint(HS_ANCHOR_R_CENTER);
m_p_shop_money->setPosition(ccp(gameGoldFrameSize.width,gameGoldFrameSize.height/2));
m_p_shop_money->setScaleX(0.7f);
gameGoldFrame->addChild(m_p_shop_money);
m_p_shop_frame = HS_FIND_UI_PANEL("UI_shangchengzu");
m_shop_frame_Position = m_p_shop_frame->getPosition();
CCSprite* shop_frame = HS_FIND_UI_PANEL_SPRITE("UI_shangchengzu","shangchengtoumingdi");
m_p_shop_listview = HSShopListView::create(shop_frame->getContentSize(),CCSizeMake(558,100),4);
CCPoint pos = CCPointZero;
pos.x = shop_frame->getPositionX() - shop_frame->getContentSize().width / 2.f + 18.f;
pos.y = shop_frame->getPositionY() - shop_frame->getContentSize().height / 2.f;
m_p_shop_listview->setPosition(pos);
shop_frame->getParent()->addChild(m_p_shop_listview,1000);
m_p_shop_listview->reloadData();
//Shop_FlyIn(*m_p_shop_frame,m_shop_frame_Position);
this->schedule(schedule_selector(HSGameShopLayer::Update));
}
示例12: updateAtlasValues
//CCLabelAtlas - Atlas generation
void CCLabelAtlas::updateAtlasValues()
{
unsigned int n = m_sString.length();
const unsigned char *s = (unsigned char*)m_sString.c_str();
CCTexture2D *texture = m_pTextureAtlas->getTexture();
float textureWide = (float) texture->getPixelsWide();
float textureHigh = (float) texture->getPixelsHigh();
float itemWidthInPixels = m_uItemWidth * CC_CONTENT_SCALE_FACTOR();
float itemHeightInPixels = m_uItemHeight * CC_CONTENT_SCALE_FACTOR();
if (m_bIgnoreContentScaleFactor)
{
itemWidthInPixels = m_uItemWidth;
itemHeightInPixels = m_uItemHeight;
}
CCAssert( n <= m_pTextureAtlas->getCapacity(), "updateAtlasValues: Invalid String length");
ccV3F_C4B_T2F_Quad* quads = m_pTextureAtlas->getQuads();
for(unsigned int i = 0; i < n; i++) {
unsigned char a = s[i] - m_uMapStartChar;
float row = (float) (a % m_uItemsPerRow);
float col = (float) (a / m_uItemsPerRow);
#if CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL
// Issue #938. Don't use texStepX & texStepY
float left = (2 * row * itemWidthInPixels + 1) / (2 * textureWide);
float right = left + (itemWidthInPixels * 2 - 2) / (2 * textureWide);
float top = (2 * col * itemHeightInPixels + 1) / (2 * textureHigh);
float bottom = top + (itemHeightInPixels * 2 - 2) / (2 * textureHigh);
#else
float left = row * itemWidthInPixels / textureWide;
float right = left + itemWidthInPixels / textureWide;
float top = col * itemHeightInPixels / textureHigh;
float bottom = top + itemHeightInPixels / textureHigh;
#endif // ! CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL
quads[i].tl.texCoords.u = left;
quads[i].tl.texCoords.v = top;
quads[i].tr.texCoords.u = right;
quads[i].tr.texCoords.v = top;
quads[i].bl.texCoords.u = left;
quads[i].bl.texCoords.v = bottom;
quads[i].br.texCoords.u = right;
quads[i].br.texCoords.v = bottom;
// quads[i].bl.vertices.x = (float) (i * m_uItemWidth);
quads[i].bl.vertices.x = (float) (i * (m_uItemWidth + m_space));
quads[i].bl.vertices.y = 0;
quads[i].bl.vertices.z = 0.0f;
// quads[i].br.vertices.x = (float)(i * m_uItemWidth + m_uItemWidth);
quads[i].br.vertices.x = (float)(i * (m_uItemWidth + m_space) + m_uItemWidth);
quads[i].br.vertices.y = 0;
quads[i].br.vertices.z = 0.0f;
// quads[i].tl.vertices.x = (float)(i * m_uItemWidth);
quads[i].tl.vertices.x = (float)(i * (m_uItemWidth + m_space));
quads[i].tl.vertices.y = (float)(m_uItemHeight);
quads[i].tl.vertices.z = 0.0f;
// quads[i].tr.vertices.x = (float)(i * m_uItemWidth + m_uItemWidth);
quads[i].tr.vertices.x = (float)(i * (m_uItemWidth + m_space) + m_uItemWidth);
quads[i].tr.vertices.y = (float)(m_uItemHeight);
quads[i].tr.vertices.z = 0.0f;
ccColor4B c = { _displayedColor.r, _displayedColor.g, _displayedColor.b, _displayedOpacity };
quads[i].tl.colors = c;
quads[i].tr.colors = c;
quads[i].bl.colors = c;
quads[i].br.colors = c;
}
if (n > 0 ){
m_pTextureAtlas->setDirty(true);
unsigned int totalQuads = m_pTextureAtlas->getTotalQuads();
if (n > totalQuads) {
m_pTextureAtlas->increaseTotalQuadsWith(n - totalQuads);
}
}
}
示例13: init
// on "init" you need to initialize your instance
bool kBaseScene::init()
{
// 0.alloc memory for shared data
ksd = new kSharedData;
// common use resource load into memory
CCTexture2D *pTextureShadow = CCTextureCache::sharedTextureCache()->addImage("yy.png");
CCSpriteFrame* shadowFrame = CCSpriteFrame::createWithTexture(pTextureShadow, CCRectMake(0, 0, pTextureShadow->getPixelsWide(), pTextureShadow->getPixelsHigh()));
CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFrame(shadowFrame, "yy.png");
// test fake data
// you should init the shared data after login scene
ksd->rd.rid = 1;
ksd->rd.mid = 1;
ksd->rd.x = 0;
ksd->rd.y = 0;
ksd->rd.lv = 18;
// test fake data over
// 1.make the network connection
int connectresult=0;
ks = new kClientSocket;
connectresult = ks->start("127.0.0.1", 8810);
if(connectresult == SOCKET_ERROR)
{
// to information and exit
CCMessageBox("wrong", "Error connect to net,check your configuration plz");
delete ks;
ks = NULL;
}
else
{
}
// 2.run base ui manager
kuimgr = kUiManager::create();
kuimgr->setTag(CLOSEABLE_LAYER_Z);
// frame view add
this->addChild(kuimgr,CLOSEABLE_LAYER_Z);
// 3.net work msg receive loop
this->schedule(schedule_selector(kBaseScene::onupdate),0.04);
// 4.create the gameview base layer
gameview = kGameView::create();
this->addChild(gameview,GAMELAYER_Z);
// should start login view here,and from login view call relate initview function to
// load view
// here.run base scene from role data for test
kSceneInterface* normapScene = kNormalMapScene::create();
char mapid[16];
sprintf(mapid,"map/%d", ksd->rd.mid);
gameview->changeScene(normapScene,mapid);
return true;
}
示例14: Load
void HSEmailSystemLayer::Load()
{
CCSprite* pBackground = HSCCSprite::create("Image/BEIJING.png");
pBackground->setPosition(HSBase::GetTemplateScreenCentre());
this->addChild(pBackground);
HSTool::SetNodeFilldScreen(pBackground);
HSReadUI::ShareReadUI()->ReadUI("Image/EmailSystem.data","Image/",this);
CCSprite* pMoneyFrame = HS_FIND_UI_PANEL_SPRITE("UI_Jinbidiandikuang","Jinbidiandikuang");
CCTexture2D* pMoneyTexture = CCTextureCache::sharedTextureCache()->addImage("Image/moneyNumber.png");
m_pMoney = CCLabelAtlas::create("0","Image/moneyNumber.png",pMoneyTexture->getPixelsWide() / 11,pMoneyTexture->getPixelsHigh(),'0');
m_pMoney->setAnchorPoint(HS_ANCHOR_CENTER);
m_pMoney->setPosition(HS_SizeHalf_Point(pMoneyFrame->getContentSize()));
pMoneyFrame->addChild(m_pMoney);
CCSprite* pEmailSystemFrame = HS_FIND_UI_PANEL_SPRITE("UI_FriendFrame","gerenxinxilanfanwei");
m_pEmailListView = HSEmailListVeiw::create(pEmailSystemFrame->getContentSize(),CCSizeMake(505,100),HS_GAME_CACHE()->m_EmailResponse.emaillist_size());
CCPoint pos = CCPointZero;
pos.x = -pEmailSystemFrame->getContentSize().width / 2.f - 15.f;
pos.y = pEmailSystemFrame->getPosition().y - pEmailSystemFrame->getContentSize().height / 2.f - 20.f;
m_pEmailListView->setPosition(pos);
pEmailSystemFrame->getParent()->addChild(m_pEmailListView,1000);
m_pEmailListView->reloadData();
HS_SET_MENU_TARGET("UI_fh_01",this,HSEmailSystemLayer::Call_Back);
HS_SET_MENU_TARGET("UI_Goumaijinbianniu_01",this,HSEmailSystemLayer::Call_Shop);
if (HS_GAME_CACHE()->m_EmailResponse.emaillist_size() == 0)
{
CCMenu* pMenu = HS_FIND_UI_MENU("UI_quanbulingqu");
pMenu->setVisible(false);
}else{
HS_SET_MENU_TARGET("UI_quanbulingqu",this,HSEmailSystemLayer::Call_AllRevc);
}
this->schedule(schedule_selector(HSEmailSystemLayer::Updata));
}
示例15: sprintf
kMainToolBarCell::kMainToolBarCell(unsigned short _t)
{
char name[16];
sprintf(name, "tb%d.png",_t);
_type = _t;
CCTexture2D *pTextureShadow = CCTextureCache::sharedTextureCache()->addImage(name);
CCSpriteFrame* shadowFrame = CCSpriteFrame::createWithTexture(pTextureShadow, CCRectMake(0, 0, pTextureShadow->getPixelsWide(), pTextureShadow->getPixelsHigh()));
CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFrame(shadowFrame, name);
CCSpriteFrame *spf2=CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(name);
// create from sprite frames cache
CCScale9Sprite *backgroundButton2 = CCScale9Sprite::createWithSpriteFrame(spf2);//
content = CCControlButton::create(backgroundButton2);
content->setTouchPriority(TOUCH_PRIORITY_MAINVIEW);
content->setTitleColorForState(ccWHITE, CCControlStateHighlighted);
content->setPreferredSize(spf2->getRect().size);
content->addTargetWithActionForControlEvents(this, cccontrol_selector(kMainToolBarCell::iambeclick), CCControlEventTouchUpInside);
_w = spf2->getRect().size.width;
_h = spf2->getRect().size.height;
content->setOpacity(0);
this->addChild(content);
}