本文整理汇总了C++中ccg函数的典型用法代码示例。如果您正苦于以下问题:C++ ccg函数的具体用法?C++ ccg怎么用?C++ ccg使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ccg函数的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: getChildByTag
void TileMapEditTest::updateMap(float dt)
{
// IMPORTANT
// The only limitation is that you cannot change an empty, or assign an empty tile to a tile
// The value 0 not rendered so don't assign or change a tile with value 0
CCTileMapAtlas* tilemap = (CCTileMapAtlas*) getChildByTag(kTagTileMap);
//
// For example you can iterate over all the tiles
// using this code, but try to avoid the iteration
// over all your tiles in every frame. It's very expensive
// for(int x=0; x < tilemap.tgaInfo->width; x++) {
// for(int y=0; y < tilemap.tgaInfo->height; y++) {
// ccColor3B c =[tilemap tileAt:ccg(x,y));
// if( c.r != 0 ) {
// ////----UXLOG("%d,%d = %d", x,y,c.r);
// }
// }
// }
// NEW since v0.7
ccColor3B c = tilemap->tileAt(ccg(13,21));
c.r++;
c.r %= 50;
if( c.r==0)
c.r=1;
// NEW since v0.7
tilemap->setTile(c, ccg(13,21) );
}
开发者ID:acc85,项目名称:cocos2d-x,代码行数:31,代码来源:TileMapTest.cpp
示例2: MAX
/*
* Update each tick
* Time is the percentage of the way through the duration
*/
void CCPageTurn3D::update(ccTime time)
{
float tt = MAX(0, time - 0.25f);
float deltaAy = (tt * tt * 500);
float ay = -100 - deltaAy;
float deltaTheta = - (float) M_PI_2 * sqrtf(time) ;
float theta = /*0.01f */ + (float) M_PI_2 +deltaTheta;
float sinTheta = sinf(theta);
float cosTheta = cosf(theta);
for (int i = 0; i <= m_sGridSize.x; ++i)
{
for (int j = 0; j <= m_sGridSize.y; ++j)
{
// Get original vertex
ccVertex3F p = originalVertex(ccg(i ,j));
float R = sqrtf((p.x * p.x) + ((p.y - ay) * (p.y - ay)));
float r = R * sinTheta;
float alpha = asinf(p.x / R);
float beta = alpha / sinTheta;
float cosBeta = cosf(beta);
// If beta > PI then we've wrapped around the cone
// Reduce the radius to stop these points interfering with others
if (beta <= M_PI)
{
p.x = (r * sinf(beta));
}
else
{
// Force X = 0 to stop wrapped
// points
p.x = 0;
}
p.y = (R + ay - (r * (1 - cosBeta) * sinTheta));
// We scale z here to avoid the animation being
// too much bigger than the screen due to perspectve transform
p.z = (r * (1 - cosBeta) * cosTheta) / 7;// "100" didn't work for
// Stop z coord from dropping beneath underlying page in a transition
// issue #751
if (p.z < 0.5f)
{
p.z = 0.5f;
}
// Set new coords
setVertex(ccg(i, j), p);
}
}
}
开发者ID:LiangYue1981816,项目名称:CrossEngine,代码行数:61,代码来源:CCActionPageTurn3D.cpp
示例3: originalVertex
void CCWaves3D::update(ccTime time)
{
int i, j;
for (i = 0; i < m_sGridSize.x + 1; ++i)
{
for (j = 0; j < m_sGridSize.y + 1; ++j)
{
ccVertex3F v = originalVertex(ccg(i ,j));
v.z += (sinf((CGFloat)M_PI * time * m_nWaves * 2 + (v.y+v.x) * .01f) * m_fAmplitude * m_fAmplitudeRate);
CCLog("v.z offset is %f\n", (sinf((CGFloat)M_PI * time * m_nWaves * 2 + (v.y+v.x) * .01f) * m_fAmplitude * m_fAmplitudeRate));
setVertex(ccg(i, j), v);
}
}
}
开发者ID:amatuer,项目名称:cocos2d-game,代码行数:14,代码来源:CCActionGrid3D.cpp
示例4: actionWithDuration
static CCActionInterval* actionWithDuration(ccTime t)
{
CCTurnOffTiles* fadeout = CCTurnOffTiles::actionWithSeed(25, ccg(48,32) , t);
CCActionInterval* back = fadeout->reverse();
CCDelayTime* delay = CCDelayTime::actionWithDuration(0.5f);
return (CCActionInterval*)(CCSequence::actions(fadeout, delay, back, NULL));
}
开发者ID:geniikw,项目名称:myFirst2DGame,代码行数:8,代码来源:EffectsTest.cpp
示例5: create
static CCActionInterval* create(float t)
{
CCTurnOffTiles* fadeout = CCTurnOffTiles::create(25, ccg(48,32) , t);
CCActionInterval* back = fadeout->reverse();
CCDelayTime* delay = CCDelayTime::create(0.5f);
return (CCActionInterval*)(CCSequence::create(fadeout, delay, back, NULL));
}
开发者ID:DangoXJ,项目名称:TuJinZhi,代码行数:8,代码来源:EffectsTest.cpp
示例6: getChildByTag
//------------------------------------------------------------------
//
// Effect3
//
//------------------------------------------------------------------
void Effect3::onEnter()
{
EffectAdvanceTextLayer::onEnter();
CCNode* bg = getChildByTag(kTagBackground);
CCNode* target1 = bg->getChildByTag(kTagSprite1);
CCNode* target2 = bg->getChildByTag(kTagSprite2);
CCActionInterval* waves = CCWaves::actionWithWaves(5, 20, true, false, ccg(15,10), 5);
CCActionInterval* shaky = CCShaky3D::actionWithRange(4, false, ccg(15,10), 5);
target1->runAction( CCRepeatForever::actionWithAction( waves ) );
target2->runAction( CCRepeatForever::actionWithAction( shaky ) );
// moving background. Testing issue #244
CCActionInterval* move = CCMoveBy::actionWithDuration(3, ccp(200,0) );
bg->runAction(CCRepeatForever::actionWithAction( (CCActionInterval *)(CCSequence::actions(move, move->reverse(), NULL) ) ) );
}
开发者ID:geniikw,项目名称:myFirst2DGame,代码行数:23,代码来源:EffectsAdvancedTest.cpp
示例7: CC_UNUSED_PARAM
void CCLens3D::update(ccTime time)
{
CC_UNUSED_PARAM(time);
if (m_bDirty)
{
int i, j;
for (i = 0; i < m_sGridSize.x + 1; ++i)
{
for (j = 0; j < m_sGridSize.y + 1; ++j)
{
ccVertex3F v = originalVertex(ccg(i, j));
CCPoint vect = ccpSub(m_positionInPixels, ccp(v.x, v.y));
CGFloat r = ccpLength(vect);
if (r < m_fRadius)
{
r = m_fRadius - r;
CGFloat pre_log = r / m_fRadius;
if ( pre_log == 0 )
{
pre_log = 0.001f;
}
float l = logf(pre_log) * m_fLensEffect;
float new_r = expf( l ) * m_fRadius;
if (ccpLength(vect) > 0)
{
vect = ccpNormalize(vect);
CCPoint new_vect = ccpMult(vect, new_r);
v.z += ccpLength(new_vect) * m_fLensEffect;
}
}
setVertex(ccg(i, j), v);
}
}
m_bDirty = false;
}
}
开发者ID:amatuer,项目名称:cocos2d-game,代码行数:42,代码来源:CCActionGrid3D.cpp
示例8: originalVertex
void CCShaky3D::update(cocos2d::ccTime time)
{
int i, j;
for (i = 0; i < (m_sGridSize.x+1); ++i)
{
for (j = 0; j < (m_sGridSize.y+1); ++j)
{
ccVertex3F v = originalVertex(ccg(i ,j));
v.x += (rand() % (m_nRandrange*2)) - m_nRandrange;
v.y += (rand() % (m_nRandrange*2)) - m_nRandrange;
if (m_bShakeZ)
{
v.z += (rand() % (m_nRandrange*2)) - m_nRandrange;
}
setVertex(ccg(i, j), v);
}
}
}
开发者ID:valentinvit,项目名称:cocos2d-x,代码行数:20,代码来源:CCActionGrid3D.cpp
示例9: ccg
ccGridSize CCShuffleTiles::getDelta(cocos2d::ccGridSize pos)
{
CGPoint pos2;
int idx = pos.x * m_sGridSize.y + pos.y;
pos2.x = (float)(m_pTilesOrder[idx] / (int)m_sGridSize.y);
pos2.y = (float)(m_pTilesOrder[idx] % (int)m_sGridSize.y);
return ccg((int)(pos2.x - pos.x), (int)(pos2.y - pos.y));
}
开发者ID:valentinvit,项目名称:cocos2d-x,代码行数:11,代码来源:CCActionTiledGrid.cpp
示例10: originalTile
void CCWavesTiles3D::update(ccTime time)
{
int i, j;
for( i = 0; i < m_sGridSize.x; i++ )
{
for( j = 0; j < m_sGridSize.y; j++ )
{
ccQuad3 coords = originalTile(ccg(i, j));
coords.bl.z = (sinf(time * (CGFloat)M_PI *m_nWaves * 2 +
(coords.bl.y+coords.bl.x) * .01f) * m_fAmplitude * m_fAmplitudeRate );
coords.br.z = coords.bl.z;
coords.tl.z = coords.bl.z;
coords.tr.z = coords.bl.z;
setTile(ccg(i, j), coords);
}
}
}
开发者ID:blakey87,项目名称:cocos2d-x-2.1.1,代码行数:20,代码来源:CCActionTiledGrid.cpp
示例11: ccg
ccGridSize CCShuffleTiles::getDelta(const ccGridSize& pos)
{
CCPoint pos2;
unsigned int idx = pos.x * m_sGridSize.y + pos.y;
pos2.x = (float)(m_pTilesOrder[idx] / (int)m_sGridSize.y);
pos2.y = (float)(m_pTilesOrder[idx] % (int)m_sGridSize.y);
return ccg((int)(pos2.x - pos.x), (int)(pos2.y - pos.y));
}
开发者ID:blakey87,项目名称:cocos2d-x-2.1.1,代码行数:11,代码来源:CCActionTiledGrid.cpp
示例12: CC_UNUSED_PARAM
void CCShaky3D::update(float time)
{
CC_UNUSED_PARAM(time);
int i, j;
for (i = 0; i < (m_sGridSize.x+1); ++i)
{
for (j = 0; j < (m_sGridSize.y+1); ++j)
{
ccVertex3F v = originalVertex(ccg(i ,j));
v.x += (rand() % (m_nRandrange*2)) - m_nRandrange;
v.y += (rand() % (m_nRandrange*2)) - m_nRandrange;
if (m_bShakeZ)
{
v.z += (rand() % (m_nRandrange*2)) - m_nRandrange;
}
setVertex(ccg(i, j), v);
}
}
}
开发者ID:suzuhiroruri,项目名称:EuropeanCharisou,代码行数:21,代码来源:CCActionGrid3D.cpp
示例13: CC_UNUSED_PARAM
void CCShatteredTiles3D::update(ccTime time)
{
CC_UNUSED_PARAM(time);
int i, j;
if (m_bOnce == false)
{
for (i = 0; i < m_sGridSize.x; ++i)
{
for (j = 0; j < m_sGridSize.y; ++j)
{
ccQuad3 coords = originalTile(ccg(i ,j));
// X
coords.bl.x += ( rand() % (m_nRandrange*2) ) - m_nRandrange;
coords.br.x += ( rand() % (m_nRandrange*2) ) - m_nRandrange;
coords.tl.x += ( rand() % (m_nRandrange*2) ) - m_nRandrange;
coords.tr.x += ( rand() % (m_nRandrange*2) ) - m_nRandrange;
// Y
coords.bl.y += ( rand() % (m_nRandrange*2) ) - m_nRandrange;
coords.br.y += ( rand() % (m_nRandrange*2) ) - m_nRandrange;
coords.tl.y += ( rand() % (m_nRandrange*2) ) - m_nRandrange;
coords.tr.y += ( rand() % (m_nRandrange*2) ) - m_nRandrange;
if (m_bShatterZ)
{
coords.bl.z += ( rand() % (m_nRandrange*2) ) - m_nRandrange;
coords.br.z += ( rand() % (m_nRandrange*2) ) - m_nRandrange;
coords.tl.z += ( rand() % (m_nRandrange*2) ) - m_nRandrange;
coords.tr.z += ( rand() % (m_nRandrange*2) ) - m_nRandrange;
}
setTile(ccg(i, j), coords);
}
}
m_bOnce = true;
}
}
开发者ID:blakey87,项目名称:cocos2d-x-2.1.1,代码行数:40,代码来源:CCActionTiledGrid.cpp
示例14: testFunc
void CCFadeOutTRTiles::update(ccTime time)
{
int i, j;
for (i = 0; i < m_sGridSize.x; ++i)
{
for (j = 0; j < m_sGridSize.y; ++j)
{
float distance = testFunc(ccg(i, j), time);
if ( distance == 0 )
{
turnOffTile(ccg(i, j));
} else if (distance < 1)
{
transformTile(ccg(i, j), distance);
}
else
{
turnOnTile(ccg(i, j));
}
}
}
}
开发者ID:blakey87,项目名称:cocos2d-x-2.1.1,代码行数:23,代码来源:CCActionTiledGrid.cpp
示例15: getChildByTag
//------------------------------------------------------------------
//
// Effect1
//
//------------------------------------------------------------------
void Effect1::onEnter()
{
EffectAdvanceTextLayer::onEnter();
CCNode* target = getChildByTag(kTagBackground);
// To reuse a grid the grid size and the grid type must be the same.
// in this case:
// Lens3D is Grid3D and it's size is (15,10)
// Waves3D is Grid3D and it's size is (15,10)
CCSize size = CCDirector::sharedDirector()->getWinSize();
CCActionInterval* lens = CCLens3D::create(ccp(size.width/2,size.height/2), 240, ccg(15,10), 0.0f);
CCActionInterval* waves = CCWaves3D::create(18, 15, ccg(15,10), 10);
CCFiniteTimeAction* reuse = CCReuseGrid::create(1);
CCActionInterval* delay = CCDelayTime::create(8);
CCActionInterval* orbit = CCOrbitCamera::create(5, 1, 2, 0, 180, 0, -90);
CCActionInterval* orbit_back = orbit->reverse();
target->runAction( CCRepeatForever::create( (CCActionInterval *)(CCSequence::create( orbit, orbit_back, NULL) ) ) );
target->runAction( CCSequence::create(lens, delay, reuse, waves, NULL) );
}
开发者ID:ZheNanXu,项目名称:Billiard-2D,代码行数:29,代码来源:EffectsAdvancedTest.cpp
示例16: ccpMult
void CCShuffleTiles::update(ccTime time)
{
int i, j;
Tile *tileArray = (Tile*)m_pTiles;
for (i = 0; i < m_sGridSize.x; ++i)
{
for (j = 0; j < m_sGridSize.y; ++j)
{
tileArray->position = ccpMult(ccp((float)tileArray->delta.x, (float)tileArray->delta.y), time);
placeTile(ccg(i, j), tileArray);
++tileArray;
}
}
}
开发者ID:blakey87,项目名称:cocos2d-x-2.1.1,代码行数:16,代码来源:CCActionTiledGrid.cpp
示例17: ccg
//------------------------------------------------------------------
//
// Effect4
//
//------------------------------------------------------------------
void Effect4::onEnter()
{
EffectAdvanceTextLayer::onEnter();
CCActionInterval* lens = CCLens3D::actionWithPosition(ccp(100,180), 150, ccg(32,24), 10);
//id move = [MoveBy::actionWithDuration:5 position:ccp(400,0)];
/**
@todo we only support CCNode run actions now.
*/
// CCActionInterval* move = CCJumpBy::actionWithDuration(5, ccp(380,0), 100, 4);
// CCActionInterval* move_back = move->reverse();
// CCActionInterval* seq = (CCActionInterval *)(CCSequence::actions( move, move_back, NULL));
// CCActionManager::sharedManager()->addAction(seq, lens, false);
runAction( lens );
}
开发者ID:geniikw,项目名称:myFirst2DGame,代码行数:22,代码来源:EffectsAdvancedTest.cpp
注:本文中的ccg函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论