本文整理汇总了C++中CCArray::release方法的典型用法代码示例。如果您正苦于以下问题:C++ CCArray::release方法的具体用法?C++ CCArray::release怎么用?C++ CCArray::release使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCArray
的用法示例。
在下文中一共展示了CCArray::release方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: checkWith
/**
* Checks the box for potential matches
* either horizontally or vertically
*/
void Box::checkWith(Orientation orient, int order)
{
CCLOG("+F Box::checkWith()");
int iMax = (orient == OrientationHori) ? size.height: size.width;
int jMax = (orient == OrientationHori) ? size.width: size.height;
for (int i=0; i<iMax; i++) {
int count = 0;
int vv = -1;
CCArray *matches = CCArray::createWithCapacity(jMax);
for (int j=0; j<jMax; j++) {
Tile2 *tile = this->objectAtX(((orient == OrientationVert)? i:j), ((orient == OrientationVert)? j :i));
if(tile->value == 0) {
readyToRemoveTiles->addObject(tile);
}
else if(tile->value == vv){
count++;
matches->addObject(tile);
} else {
// current streak has been broken
this->doCombinations(count, matches, orient, order);
count = 1;
matches->removeAllObjects();
matches->addObject(tile);
vv = tile->value;
}
}
this->doCombinations(count, matches, orient, order);
matches->removeAllObjects();
matches->release();
}
CCLOG("+F Box::checkWith()");
}
示例2: attack
SGAttackInfo SGMonster::attack() {
atkState = MONSTER_ATK_PREV;
int actWhat = selectAttack();
CCLog("Monster Attack Dir = %d", actWhat);
nowAttackInfo.atk = this->atk;
nowAttackInfo.atkDir = act_attack[actWhat].atkDir;
nowAttackInfo.nFrames = act_attack[actWhat].nFrames;
int frame1, frame2;
frame1 = nowAttackInfo.nFrames / 2;
if(nowAttackInfo.nFrames%2 == 0) frame2 = frame1;
else frame2 = frame1 + 1;
monsterSprite->stopAllActions();
func_attack_first();
CCArray* pAttackChange = CCArray::create();
pAttackChange->retain();
pAttackChange->addObject(CCDelayTime::create(GAME_FRAME_SPEED*(frame1)));
pAttackChange->addObject(CCCallFunc::create(this, callfunc_selector(SGMonster::func_attack_second)));
pAttackChange->addObject(CCDelayTime::create(GAME_FRAME_SPEED*(frame2)));
pAttackChange->addObject(CCCallFunc::create(this, callfunc_selector(SGMonster::func_attack_end)));
pAttackChange->addObject(CCDelayTime::create(GAME_FRAME_SPEED));
monsterSprite->runAction(CCSpawn::create(act_attack[actWhat].act_attack,
CCSequence::create(pAttackChange)));
pAttackChange->release();
return nowAttackInfo;
}
示例3: createWithVoid
CCPriest* CCPriest::createWithVoid()
{
CCPriest* pCCPriest = CCPriest::create();
//读取plist
CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("Priests_0.plist", "Priests_0.png");
//生成站立动画
CCArray *frames = CCArray::create();
for( int i=0; i<6; i++ )
{
char pngName[30];
sprintf(pngName, "Priests_0%d.png", i+1);
CCSpriteFrame *frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(pngName);
frames->addObject(frame);
}
CCAnimation* pStand = CCAnimation::createWithSpriteFrames(frames, 1./6);
frames->release();
pCCPriest->setScaleX(-0.8);
pCCPriest->setScaleY(0.8);
pCCPriest->m_pStand = CCAnimate::create(pStand);
pCCPriest->runAction(CCRepeatForever::create(pCCPriest->m_pStand));
return pCCPriest;
}
示例4: array_Value
static void array_Value(CCArray * aArray, const cocos2d::ValueVector & value)
{
cocos2d::ValueVector::const_iterator beg = value.begin();
cocos2d::ValueVector::const_iterator end = value.end();
for (; beg != end; ++beg)
{
const Value & v = *beg;
if (v.getType() == Value::Type::MAP)
{
CCDictionary * dict = new CCDictionary();
dict->init();
dictionary_Value(dict, v.asValueMap());
aArray->addObject(dict);
dict->release();
}
else if (v.getType() == Value::Type::VECTOR)
{
CCArray * arr = new CCArray();
arr->init();
array_Value(arr, v.asValueVector());
aArray->addObject(arr);
arr->release();
}
else
{
CCString * str = new CCString();
if (v.getType() == Value::Type::DOUBLE)
str->initWithFormat("%f", v.asDouble());
else
str->initWithFormat("%s", v.asString().c_str());
aArray->addObject(str);
str->release();
}
}
}
示例5: copyWithZone
CCObject* CCPointArray::copyWithZone(cocos2d::CCZone *zone)
{
CCArray *newArray = (CCArray*)m_pControlPoints->copy();
CCPointArray *points = CCPointArray::create(10);
points->retain();
points->setControlPoints(newArray);
newArray->release();
return points;
}
示例6: CCLOG
void CCAnimationCache::parseVersion1(CCDictionary* animations)
{
CCSpriteFrameCache *frameCache = CCSpriteFrameCache::sharedSpriteFrameCache();
CCDictElement* pElement = NULL;
CCDICT_FOREACH(animations, pElement)
{
CCDictionary* animationDict = (CCDictionary*)pElement->getObject();
CCArray* frameNames = (CCArray*)animationDict->objectForKey("frames");
float delay = animationDict->valueForKey("delay")->floatValue();
CCAnimation* animation = NULL;
if ( frameNames == NULL )
{
CCLOG("cocos2d: CCAnimationCache: Animation '%s' found in dictionary without any frames - cannot add to animation cache.", pElement->getStrKey());
continue;
}
CCArray* frames = CCArray::createWithCapacity(frameNames->count());
frames->retain();
CCObject* pObj = NULL;
CCARRAY_FOREACH(frameNames, pObj)
{
const char* frameName = ((CCString*)pObj)->getCString();
CCSpriteFrame* spriteFrame = frameCache->spriteFrameByName(frameName);
if ( ! spriteFrame ) {
CCLOG("cocos2d: CCAnimationCache: Animation '%s' refers to frame '%s' which is not currently in the CCSpriteFrameCache. This frame will not be added to the animation.", pElement->getStrKey(), frameName);
continue;
}
CCAnimationFrame* animFrame = new CCAnimationFrame();
animFrame->initWithSpriteFrame(spriteFrame, 1, NULL);
frames->addObject(animFrame);
animFrame->release();
}
if ( frames->count() == 0 ) {
CCLOG("cocos2d: CCAnimationCache: None of the frames for animation '%s' were found in the CCSpriteFrameCache. Animation is not being added to the Animation Cache.", pElement->getStrKey());
continue;
} else if ( frames->count() != frameNames->count() ) {
CCLOG("cocos2d: CCAnimationCache: An animation in your dictionary refers to a frame which is not in the CCSpriteFrameCache. Some or all of the frames for the animation '%s' may be missing.", pElement->getStrKey());
}
animation = CCAnimation::create(frames, delay, 1);
CCAnimationCache::sharedAnimationCache()->addAnimation(animation, pElement->getStrKey());
frames->release();
}
示例7: reverse
CCPointArray* CCPointArray::reverse()
{
CCArray *newArray = new CCArray(m_pControlPoints->count());
for (int i = m_pControlPoints->count()-1; i >= 0; --i)
{
newArray->addObject(m_pControlPoints->objectAtIndex(i));
}
CCPointArray *config = CCPointArray::create(0);
config->setControlPoints(newArray);
newArray->release();
return config;
}
示例8: createBiqiSmile
CCAnimation* AnimationManager::createBiqiSmile()
{
CCSpriteFrame *frame0, *frame1,*frame2;
CCArray* animFrames =CCArray::createWithCapacity(3);
frame0=CCSpriteFrame::create("Startup_herface1.png",CCRectMake(0,0,97,92));
frame1=CCSpriteFrame::create("Startup_herface2.png",CCRectMake(0,0,97,92));
frame2=CCSpriteFrame::create("Startup_herface3.png",CCRectMake(0,0,97,92));
animFrames->addObject(frame0);
animFrames->addObject(frame1);
animFrames->addObject(frame2);
CCAnimation* animation = CCAnimation::createWithSpriteFrames(animFrames, 0.6f);
animFrames->release();
return animation;
}
示例9: createVictoryAnimation
CCAnimation* AnimationManager::createVictoryAnimation()
{
CCSpriteFrame *frame0, *frame1;
CCArray* animFrames =CCArray::createWithCapacity(2);
frame0=CCSpriteFrame::create("Navigator_win_image_2.png",CCRectMake(0,0,179,176));
frame1=CCSpriteFrame::create("Navigator_win_image_1.png",CCRectMake(0,0,179,176));
animFrames->addObject(frame0);
animFrames->addObject(frame1);
CCAnimation* animation = CCAnimation::createWithSpriteFrames(animFrames, 0.1f);
animFrames->release();
return animation;
}
示例10: CreateThreeWheelerAnimation
void Player::CreateThreeWheelerAnimation()
{
CCArray *allFrames = new CCArray();
for (int i = 1 ; i <= 5 ; i++)
{
char fn[64];
sprintf(fn, "wheeler00%d.png" , i );
allFrames->addObject(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(fn));
}
CCAnimation *wheelerAnim = CCAnimation::createWithSpriteFrames(allFrames, 0.08f );
threeWheelerAction = CCRepeatForever::create(CCAnimate::create(wheelerAnim));
threeWheelerAction->retain();
allFrames->removeAllObjects();
allFrames->release();
}
示例11: getSyncTempCommandsContent
bool Picture::getSyncTempCommandsContent(int maxCount, string &commandsContent, int &commandsCount, bool &hasMore)
{
int totalCommandCount = mTempCommandList->count();
Json::Value rootNode;
hasMore = false;
commandsCount = 0;
CCArray *removeArray = CCArray::create();
for(int i=0;i<totalCommandCount;i++)
{
DrawCommand *drawCommand = (DrawCommand *)mTempCommandList->objectAtIndex(i);
if (drawCommand->mCommandType != DRAW_LINE) {
continue;
}
Json::Value item;
item["id"] = drawCommand->mCommandId;
item["fromX"] = drawCommand->mFromPoint.x;
item["fromY"] = drawCommand->mFromPoint.y;
item["toX"] = drawCommand->mToPoint.x;
item["toY"] = drawCommand->mToPoint.y;
item["type"] = drawCommand->mCommandType;
rootNode.append(item);
removeArray->addObject(drawCommand);
if (++commandsCount >= maxCount) {
if (i <= totalCommandCount - 1) {
hasMore = true;
}
break;
}
}
if (commandsCount <= 0) {
return false;
}
commandsContent = rootNode.toStyledString();
mTempCommandList->removeObjectsInArray(removeArray);
removeArray->release();
return true;
}
示例12: PlayMonsterWalkAnimation
void CrazyZombieBomber::PlayMonsterWalkAnimation()
{
float scaleFactor = CCDirector::sharedDirector()->getContentScaleFactor();
float x = 32 / scaleFactor;
float y = 48 / scaleFactor;
CCSpriteFrame *frame0=CCSpriteFrame::create("CrazyZombieBomber.png",CCRectMake(0, 0, x, y));
CCSpriteFrame *frame1=CCSpriteFrame::create("CrazyZombieBomber.png",CCRectMake(x, 0, x, y));
CCSpriteFrame *frame2=CCSpriteFrame::create("CrazyZombieBomber.png",CCRectMake(x*2, 0, x, y));
CCSpriteFrame *frame3=CCSpriteFrame::create("CrazyZombieBomber.png",CCRectMake(x*3, 0, x, y));
CCArray *animFrames = new CCArray;
animFrames->addObject(frame0);
animFrames->addObject(frame1);
animFrames->addObject(frame2);
animFrames->addObject(frame3);
CCAnimation *pAnim = CCAnimation::createWithSpriteFrames(animFrames, 0.4f);
animFrames->release();
m_pMainSprite->runAction(CCRepeatForever::create(CCAnimate::create(pAnim)));
}
示例13: getUserResultHandler
void getUserResultHandler(C2DXResponseState state, C2DXPlatType platType, CCDictionary *userInfo, CCDictionary *error)
{
if (state == C2DXResponseStateSuccess)
{
//输出用户信息
try
{
CCArray *allKeys = userInfo -> allKeys();
allKeys->retain();
for (int i = 0; i < allKeys -> count(); i++)
{
CCString *key = (CCString *)allKeys -> objectAtIndex(i);
CCObject *obj = userInfo -> objectForKey(key -> getCString());
CCLog("key = %s", key -> getCString());
if (dynamic_cast<CCString *>(obj))
{
CCLog("value = %s", dynamic_cast<CCString *>(obj) -> getCString());
}
else if (dynamic_cast<CCInteger *>(obj))
{
CCLog("value = %d", dynamic_cast<CCInteger *>(obj) -> getValue());
}
else if (dynamic_cast<CCDouble *>(obj))
{
CCLog("value = %f", dynamic_cast<CCDouble *>(obj) -> getValue());
}
}
allKeys->release();
}
catch(...)
{
CCLog("==============error");
}
}
}
示例14: createHeroMovingAnimationByDirection
CCAnimation* AnimationManager::createHeroMovingAnimationByDirection(HeroDirection direction)
{
CCTexture2D *heroTexture = CCTextureCache::sharedTextureCache()->addImage("Hero_image.png");
CCSpriteFrame *frame0, *frame1, *frame2;
CCArray* animFrames ;
//第二个参数表示显示区域的x, y, width, height,根据direction来确定显示的y坐标
frame0 = CCSpriteFrame::createWithTexture(heroTexture, cocos2d::CCRectMake(eSize*0, eSize*direction, eSize, eSize));
frame1 = CCSpriteFrame::createWithTexture(heroTexture, cocos2d::CCRectMake(eSize*1, eSize*direction, eSize, eSize));
animFrames = new CCArray(2);
animFrames->addObject(frame0);
animFrames->addObject(frame1);
CCAnimation* animation = CCAnimation::createWithSpriteFrames(animFrames, 0.09f);
animFrames->release();
return animation;
}
示例15: dictionary_Value
static void dictionary_Value(CCDictionary * aDict, const cocos2d::ValueMap & value)
{
cocos2d::ValueMap::const_iterator beg = value.begin();
cocos2d::ValueMap::const_iterator end = value.end();
for (; beg != end; ++beg)
{
const std::string & key = (*beg).first;
const cocos2d::Value & v = (*beg).second;
if (v.getType() == Value::Type::MAP)
{
CCDictionary * d = new CCDictionary();
d->init();
dictionary_Value(d, v.asValueMap());
aDict->setObject(d, key);
d->release();
}
else if (v.getType() == Value::Type::VECTOR)
{
CCArray * a = new CCArray();
a->init();
array_Value(a, v.asValueVector());
aDict->setObject(a, key);
a->release();
}
else
{
CCString * str = new CCString();
if (v.getType() == Value::Type::DOUBLE)
str->initWithFormat("%f", v.asDouble());
else
str->initWithFormat("%s", v.asString().c_str());
aDict->setObject(str, key);
str->release();
}
}
}