void CCSkeletonAnimation::setMix (const char* fromAnimation, const char* toAnimation, float duration, int stateIndex) { CCAssert(stateIndex >= 0 && stateIndex < (int)states.size(), "stateIndex out of range."); AnimationStateData_setMixByName(states[stateIndex]->data, fromAnimation, toAnimation, duration); }
float CCParticleSystem::getEndRadiusVar() { CCAssert( m_nEmitterMode == kCCParticleModeRadius, "Particle Mode should be Radius"); return modeB.endRadiusVar; }
float CCParticleSystem::getRotatePerSecondVar() { CCAssert( m_nEmitterMode == kCCParticleModeRadius, "Particle Mode should be Radius"); return modeB.rotatePerSecondVar; }
float CCParticleSystem::getSpeedVar() { CCAssert( m_nEmitterMode == kCCParticleModeGravity, "Particle Mode should be Gravity"); return modeA.speedVar; }
void CCParticleSystem::setStartRadiusVar(float startRadiusVar) { CCAssert( m_nEmitterMode == kCCParticleModeRadius, "Particle Mode should be Radius"); modeB.startRadiusVar = startRadiusVar; }
float CCParticleSystem::getRadialAccelVar() { CCAssert( m_nEmitterMode == kCCParticleModeGravity, "Particle Mode should be Gravity"); return modeA.radialAccelVar; }
const CCPoint& CCParticleSystem::getGravity() { CCAssert( m_nEmitterMode == kCCParticleModeGravity, "Particle Mode should be Gravity"); return modeA.gravity; }
CCProgressTimer* CCTransitionProgress::progressTimerNodeWithRenderTexture(CCRenderTexture* texture) { CCAssert(false, "override me - abstract class"); return NULL; }
void CCTextureAtlas::moveQuadsFromIndex(unsigned int index, unsigned int newIndex) { CCAssert(newIndex + (m_uTotalQuads - index) <= m_uCapacity, "moveQuadsFromIndex move is out of bounds"); memmove(m_pQuads + newIndex,m_pQuads + index, (m_uTotalQuads - index) * sizeof(m_pQuads[0])); }
bool VVAlertView::init() { CCAssert(0, "use initWithTitle()"); }
VVAlertView::VVAlertView() { CCAssert(0, "Use other constructor"); }
void CCObject::retain(void) { CCAssert(m_uReference > 0, "reference count should greater than 0"); ++m_uReference; }
void CCSkeletonAnimation::clearAnimation (int stateIndex) { CCAssert(stateIndex >= 0 && stateIndex < (int)states.size(), "stateIndex out of range."); AnimationState_clearAnimation(states[stateIndex]); }
void CCSkeletonAnimation::addAnimation (const char* name, bool loop, float delay, int stateIndex) { CCAssert(stateIndex >= 0 && stateIndex < (int)states.size(), "stateIndex out of range."); AnimationState_addAnimationByName(states[stateIndex], name, loop, delay); }
float CCParticleSystem::getTangentialAccel() { CCAssert( m_nEmitterMode == kCCParticleModeGravity, "Particle Mode should be Gravity"); return modeA.tangentialAccel; }
void Widget::addChild(CCNode* child, int zOrder, int tag) { CCAssert(dynamic_cast<Widget*>(child) != NULL, "Widget only supports Widgets as children"); CCNode::addChild(child, zOrder, tag); _widgetChildren->addObject(child); }
void CCParticleSystem::setRadialAccelVar(float t) { CCAssert( m_nEmitterMode == kCCParticleModeGravity, "Particle Mode should be Gravity"); modeA.radialAccelVar = t; }
void RSimpleHTMLParser::startElement(void *ctx, const char *name, const char **atts) { //CCLog("[Parser Start]%s", name); IRichElement* element = NULL; if ( 0 == strcmp(name, "br") ) { element = new REleHTMLBR; } else if ( 0 == strcmp(name, "u") ) { element = new REleHTMLU; } else if ( 0 == strcmp(name, "font") ) { element = new REleHTMLFont; } else if ( 0 == strcmp(name, "table") ) { element = new REleHTMLTable; } else if ( 0 == strcmp(name, "tr") ) { if ( dynamic_cast<REleHTMLTable*>(m_rCurrentElement) ) { element = new REleHTMLRow(dynamic_cast<REleHTMLTable*>(m_rCurrentElement)); } } else if ( 0 == strcmp(name, "td") ) { if ( dynamic_cast<REleHTMLRow*>(m_rCurrentElement) ) { element = new REleHTMLCell(dynamic_cast<REleHTMLRow*>(m_rCurrentElement)); } } else if ( 0 == strcmp(name, "a") ) { element = new REleHTMLAnchor; } else if ( 0 == strcmp(name, "button") ) { element = new REleHTMLButton; } else if ( 0 == strcmp(name, "img") ) { element = new REleHTMLImg; } else if ( 0 == strcmp(name, "ccb") ) { element = new REleCCBNode; } else if ( 0 == strcmp(name, "hr") ) { element = new REleHTMLHR; } else if ( 0 == strcmp(name, "p") ) { element = new REleHTMLP; } else if ( 0 == strcmp(name, "node") || 0 == strcmp(name, "root") || 0 == strcmp(name, "body") ) { element = new REleHTMLRoot; } if ( !element ) { // tag not supported yet! element = new REleHTMLNotSupport; } CCAssert(element, ""); element->parse(this, atts); if ( !m_rCurrentElement ) { m_rElements->push_back(element); } else { m_rCurrentElement->addChildren(element); } m_rCurrentElement = element; }
void CCParticleSystem::setGravity(const CCPoint& g) { CCAssert( m_nEmitterMode == kCCParticleModeGravity, "Particle Mode should be Gravity"); modeA.gravity = g; }
////////////////////////////////////////////////////////////////////////// // FightScript ////////////////////////////////////////////////////////////////////////// bool FightScript::isEqual(const FightScript& test) { #define BREAK 1 FightScript testCopy = test; // InitChessBoard for (int i=0;i<FormationHeroAcountMax;i++) { if (test.init.myCurBloodNum != init.myCurBloodNum || test.init.myDefaultBloodNum != init.myDefaultBloodNum || test.init.oppositeCurBloodNum != init.oppositeCurBloodNum || test.init.oppositeDefaultBloodNum != init.oppositeDefaultBloodNum ) { #if BREAK == 1 CCAssert(false,""); #endif return false; } if (test.init.myTeam[i].heroId != init.myTeam[i].heroId || test.init.myTeam[i].hp != init.myTeam[i].hp || test.init.myTeam[i].defaultHp != init.myTeam[i].defaultHp || test.init.myTeam[i].defaultCdTime != init.myTeam[i].defaultCdTime || test.init.myTeam[i].level != init.myTeam[i].level || test.init.myTeam[i].stage != init.myTeam[i].stage || test.init.myTeam[i].profession_id != init.myTeam[i].profession_id || test.init.myTeam[i].summary_equips.size() != init.myTeam[i].summary_equips.size() || test.init.myTeam[i].x_size != init.myTeam[i].x_size || test.init.myTeam[i].hero_type != init.myTeam[i].hero_type || test.init.myTeamUniqueId[i] != init.myTeamUniqueId[i] ) { #if BREAK == 1 CCAssert(false,""); #endif return false; } // ×°±¸ { int equipNum = test.init.myTeam[i].summary_equips.size(); for (int e = 0;e<equipNum;e++) { if (test.init.myTeam[i].summary_equips[e].zhuangbei_colour != init.myTeam[i].summary_equips[e].zhuangbei_colour || test.init.myTeam[i].summary_equips[e].zhuangbei_type != init.myTeam[i].summary_equips[e].zhuangbei_type || strcmp(test.init.myTeam[i].summary_equips[e].zhuangbei_pic,init.myTeam[i].summary_equips[e].zhuangbei_pic) != 0) { #if BREAK == 1 CCAssert(false,""); #endif return false; } } } if (test.init.oppositeTeam[i].heroId != init.oppositeTeam[i].heroId || test.init.oppositeTeam[i].hp != init.oppositeTeam[i].hp || test.init.oppositeTeam[i].defaultHp != init.oppositeTeam[i].defaultHp || test.init.oppositeTeam[i].defaultCdTime != init.oppositeTeam[i].defaultCdTime || test.init.oppositeTeam[i].level != init.oppositeTeam[i].level || test.init.oppositeTeam[i].stage != init.oppositeTeam[i].stage || test.init.oppositeTeam[i].profession_id != init.oppositeTeam[i].profession_id|| test.init.oppositeTeam[i].summary_equips.size() != init.oppositeTeam[i].summary_equips.size() || test.init.oppositeTeam[i].x_size != init.oppositeTeam[i].x_size|| test.init.oppositeTeam[i].hero_type != init.oppositeTeam[i].hero_type|| test.init.oppositeUniqueId[i] != init.oppositeUniqueId[i] ) { #if BREAK == 1 CCAssert(false,""); #endif return false; } // ×°±¸ { int equipNum = test.init.oppositeTeam[i].summary_equips.size(); for (int e = 0;e<equipNum;e++) { if (test.init.oppositeTeam[i].summary_equips[e].zhuangbei_colour != init.oppositeTeam[i].summary_equips[e].zhuangbei_colour || test.init.oppositeTeam[i].summary_equips[e].zhuangbei_type != init.oppositeTeam[i].summary_equips[e].zhuangbei_type || strcmp(test.init.oppositeTeam[i].summary_equips[e].zhuangbei_pic,init.oppositeTeam[i].summary_equips[e].zhuangbei_pic) != 0) { #if BREAK == 1 CCAssert(false,""); #endif return false; } } } } // Step int stepNum = stepVec.size(); if (stepNum != test.stepVec.size()) { #if BREAK == 1 CCAssert(false,""); #endif return false; } for (int i=0;i<stepNum;i++) { if (stepVec[i].stepType != test.stepVec[i].stepType) { #if BREAK == 1 CCAssert(false,""); #endif return false; } if (stepVec[i].getBuffString() != testCopy.stepVec[i].getBuffString()) { #if BREAK == 1 CCAssert(false,""); #endif return false; } if (stepVec[i].getCurrentCdTimeString() != testCopy.stepVec[i].getCurrentCdTimeString()) { #if BREAK == 1 CCAssert(false,""); #endif return false; } if (stepVec[i].stepType == StepType_Fight) { if (stepVec[i].fightData.fightPattern != test.stepVec[i].fightData.fightPattern || stepVec[i].fightData.fightorUniqueId != test.stepVec[i].fightData.fightorUniqueId || stepVec[i].fightData.targetUniqueVec.size() != test.stepVec[i].fightData.targetUniqueVec.size() ) { #if BREAK == 1 CCAssert(false,""); #endif return false; } int targetNum = stepVec[i].fightData.targetUniqueVec.size(); for (int j=0;j<targetNum;j++) { if (stepVec[i].fightData.targetUniqueVec[j] != test.stepVec[i].fightData.targetUniqueVec[j] || stepVec[i].fightData.targetBloodChange[j] != test.stepVec[i].fightData.targetBloodChange[j] || stepVec[i].fightData.canMissVec[j] != test.stepVec[i].fightData.canMissVec[j] ) { #if BREAK == 1 CCAssert(false,""); #endif return false; } } } else if (stepVec[i].stepType == StepType_Move) { if (stepVec[i].moveData.destIndex != test.stepVec[i].moveData.destIndex || stepVec[i].moveData.uniqueId != test.stepVec[i].moveData.uniqueId || stepVec[i].moveData.inSelfChessBoard != test.stepVec[i].moveData.inSelfChessBoard ) { #if BREAK == 1 CCAssert(false,""); #endif return false; } } else if (stepVec[i].stepType == StepType_Skill) { if (stepVec[i].skillData.skillType != test.stepVec[i].skillData.skillType || stepVec[i].skillData.fightorUniqueId != test.stepVec[i].skillData.fightorUniqueId || stepVec[i].skillData.skillPatten != test.stepVec[i].skillData.skillPatten || stepVec[i].skillData.firedBuff.size() != test.stepVec[i].skillData.firedBuff.size() || stepVec[i].skillData.targetUniqueVec.size() != test.stepVec[i].skillData.targetUniqueVec.size() ) { #if BREAK == 1 CCAssert(false,""); #endif return false; } int targetNum = stepVec[i].skillData.targetUniqueVec.size(); for (int j=0;j<targetNum;j++) { if (stepVec[i].skillData.targetUniqueVec[j] != test.stepVec[i].skillData.targetUniqueVec[j] || stepVec[i].skillData.targetBloodChange[j] != test.stepVec[i].skillData.targetBloodChange[j] || stepVec[i].skillData.canMissVec[j] != test.stepVec[i].skillData.canMissVec[j] ) { #if BREAK == 1 CCAssert(false,""); #endif return false; } } int buffNum = stepVec[i].skillData.firedBuff.size(); for (int j=0;j<buffNum;j++) { if (stepVec[i].skillData.firedBuff[j].getLog() != testCopy.stepVec[i].skillData.firedBuff[j].getLog()) { #if BREAK == 1 CCAssert(false,""); #endif return false; } } } else if (stepVec[i].stepType == StepType_Wait) { // do nothing } else if(stepVec[i].stepType == StepType_ChangeRound) { if (stepVec[i].changeRound.round != test.stepVec[i].changeRound.round) { #if BREAK == 1 CCAssert(false,""); #endif return false; } } else if (stepVec[i].stepType == StepType_UseBlood || stepVec[i].stepType == StepType_ReLoadBlood) { if (stepVec[i].useBlood.uniqueId != test.stepVec[i].useBlood.uniqueId || stepVec[i].useBlood.bloodChangeForUser != test.stepVec[i].useBlood.bloodChangeForUser ) { #if BREAK == 1 CCAssert(false,""); #endif return false; } } else if (stepVec[i].stepType == StepType_FailByTakeTooMuchTime) { // do nothing } else { CCAssert(false,""); } } // Resullt if (endResult.myResult != test.endResult.myResult || endResult.gettedExp != test.endResult.gettedExp || endResult.gettedItemSuiPian.size() != test.endResult.gettedItemSuiPian.size() || endResult.gettedShenBingSuiPian.size() != test.endResult.gettedShenBingSuiPian.size() || endResult.gettedItem.size() != test.endResult.gettedItem.size() || endResult.gettedPowerPoints.size() != test.endResult.gettedPowerPoints.size() || endResult.gettedZhuangBei.size() != test.endResult.gettedZhuangBei.size()) { #if BREAK == 1 CCAssert(false,""); #endif return false; } for (int i=0;i<FormationHeroAcountMax;i++) { /*if (endResult.heroDetailAttrAfterFight[i].basic_info.hero_id != test.endResult.heroDetailAttrAfterFight[i].basic_info.hero_id || endResult.heroDetailAttrAfterFight[i].basic_info.level != test.endResult.heroDetailAttrAfterFight[i].basic_info.level || endResult.heroDetailAttrAfterFight[i].basic_info.stage != test.endResult.heroDetailAttrAfterFight[i].basic_info.stage || endResult.heroDetailAttrAfterFight[i].basic_info.is_yuanshen != test.endResult.heroDetailAttrAfterFight[i].basic_info.is_yuanshen || endResult.heroDetailAttrAfterFight[i].basic_info.hero_id != test.endResult.heroDetailAttrAfterFight[i].basic_info.hero_id || endResult.heroDetailAttrAfterFight[i].basic_info.vip_level != test.endResult.heroDetailAttrAfterFight[i].basic_info.vip_level || endResult.heroDetailAttrAfterFight[i].basic_info.profession_id != test.endResult.heroDetailAttrAfterFight[i].basic_info.profession_id || strcmp(endResult.heroDetailAttrAfterFight[i].basic_info.name,test.endResult.heroDetailAttrAfterFight[i].basic_info.name) != 0 ) { #if BREAK == 1 CCAssert(false,""); #endif return false; }*/ /*if (endResult.heroDetailAttrAfterFight[i].exp_current != test.endResult.heroDetailAttrAfterFight[i].exp_current || endResult.heroDetailAttrAfterFight[i].exp_need != test.endResult.heroDetailAttrAfterFight[i].exp_need || endResult.heroDetailAttrAfterFight[i].parent_hero_id != test.endResult.heroDetailAttrAfterFight[i].parent_hero_id || endResult.heroDetailAttrAfterFight[i].postion != test.endResult.heroDetailAttrAfterFight[i].postion || endResult.heroDetailAttrAfterFight[i].vit_current != test.endResult.heroDetailAttrAfterFight[i].vit_current ) { #if BREAK == 1 CCAssert(false,""); #endif return false; } if (0 != memcmp(&endResult.heroDetailAttrAfterFight[i].hero_attr_without_zhuangbei, &test.endResult.heroDetailAttrAfterFight[i].hero_attr_without_zhuangbei,sizeof(HeroAttrWithoutZhuangbei))) { #if BREAK == 1 CCAssert(false,""); #endif return false; }*/ } int item_sui_pian_num = endResult.gettedItemSuiPian.size(); for (int i=0;i<item_sui_pian_num;i++) { if ( memcmp(&endResult.gettedItemSuiPian[i],&(test.endResult.gettedItemSuiPian[i]),sizeof(ItemSuipianInfo) ) != 0) { #if BREAK == 1 CCAssert(false,""); #endif return false; } } int shengbing_sui_pian_num = endResult.gettedShenBingSuiPian.size(); for (int i=0;i<shengbing_sui_pian_num;i++) { if ( memcmp(&endResult.gettedShenBingSuiPian[i],&(test.endResult.gettedShenBingSuiPian[i]),sizeof(ShenbingSuipianInfo) ) != 0) { #if BREAK == 1 CCAssert(false,""); #endif return false; } } int zhuangbeiNum = endResult.gettedZhuangBei.size(); for (int i=0;i<zhuangbeiNum;i++) { if (endResult.gettedZhuangBei[i].isEqual(test.endResult.gettedZhuangBei[i])) { } else { #if BREAK == 1 CCAssert(false,""); #endif return false; } } int itemNum = endResult.gettedItem.size(); for (int i=0;i<itemNum;i++) { if (endResult.gettedItem[i].count != test.endResult.gettedItem[i].count || endResult.gettedItem[i].type != test.endResult.gettedItem[i].type ) { #if BREAK == 1 CCAssert(false,""); #endif return false; } } int powerNum = endResult.gettedPowerPoints.size(); for (int i=0;i<powerNum;i++) { if (endResult.gettedPowerPoints[i].power != test.endResult.gettedPowerPoints[i].power) { #if BREAK == 1 CCAssert(false,""); #endif return false; } } return true; }
void CCParticleSystem::setSpeedVar(float speedVar) { CCAssert( m_nEmitterMode == kCCParticleModeGravity, "Particle Mode should be Gravity"); modeA.speedVar = speedVar; }
void startElement(void *ctx, const char *name, const char **atts) { CC_UNUSED_PARAM(ctx); CC_UNUSED_PARAM(atts); std::string sName((char*)name); if( sName == "dict" ) { m_pCurDict = new CCDictionary(); if (m_eResultType == SAX_RESULT_DICT && ! m_pRootDict) { // Because it will call m_pCurDict->release() later, so retain here. m_pRootDict = m_pCurDict; m_pRootDict->retain(); } m_tState = SAX_DICT; CCSAXState preState = SAX_NONE; if (! m_tStateStack.empty()) { preState = m_tStateStack.top(); } if (SAX_ARRAY == preState) { // add the dictionary into the array m_pArray->addObject(m_pCurDict); } else if (SAX_DICT == preState) { // add the dictionary into the pre dictionary CCAssert(! m_tDictStack.empty(), "The state is wrong!"); CCDictionary* pPreDict = m_tDictStack.top(); pPreDict->setObject(m_pCurDict, m_sCurKey); } m_pCurDict->release(); // record the dict state m_tStateStack.push(m_tState); m_tDictStack.push(m_pCurDict); } else if(sName == "key") { m_tState = SAX_KEY; } else if(sName == "integer") { m_tState = SAX_INT; } else if(sName == "real") { m_tState = SAX_REAL; } else if(sName == "string") { m_tState = SAX_STRING; } else if (sName == "array") { m_tState = SAX_ARRAY; m_pArray = new CCArray(); if (m_eResultType == SAX_RESULT_ARRAY && m_pRootArray == NULL) { m_pRootArray = m_pArray; m_pRootArray->retain(); } CCSAXState preState = SAX_NONE; if (! m_tStateStack.empty()) { preState = m_tStateStack.top(); } //CCSAXState preState = m_tStateStack.empty() ? SAX_DICT : m_tStateStack.top(); if (preState == SAX_DICT) { m_pCurDict->setObject(m_pArray, m_sCurKey); } else if (preState == SAX_ARRAY) { CCAssert(! m_tArrayStack.empty(), "The state is worng!"); CCArray* pPreArray = m_tArrayStack.top(); pPreArray->addObject(m_pArray); } m_pArray->release(); // record the array state m_tStateStack.push(m_tState); m_tArrayStack.push(m_pArray); } else { m_tState = SAX_NONE; } }
float CCParticleSystem::getStartRadius() { CCAssert( m_nEmitterMode == kCCParticleModeRadius, "Particle Mode should be Radius"); return modeB.startRadius; }
void AIActionMove::startWithTarget(CCNode *pTarget){ AIAction::startWithTarget(pTarget); Character *character = dynamic_cast<Character*>(actionOwner); CCAssert(character, "Not Character class"); actionOwnerCharacter = character; }
void CCParticleSystem::setEndRadiusVar(float endRadiusVar) { CCAssert( m_nEmitterMode == kCCParticleModeRadius, "Particle Mode should be Radius"); modeB.endRadiusVar = endRadiusVar; }
bool CCParticleSystem::initWithDictionary(CCDictionary<std::string, CCObject*> *dictionary) { bool bRet = false; unsigned char *buffer = NULL; unsigned char *deflated = NULL; CCImage *image = NULL; do { int maxParticles = atoi(valueForKey("maxParticles", dictionary)); // self, not super if(this->initWithTotalParticles(maxParticles)) { // angle m_fAngle = (float)atof(valueForKey("angle", dictionary)); m_fAngleVar = (float)atof(valueForKey("angleVariance", dictionary)); // duration m_fDuration = (float)atof(valueForKey("duration", dictionary)); // blend function m_tBlendFunc.src = atoi(valueForKey("blendFuncSource", dictionary)); m_tBlendFunc.dst = atoi(valueForKey("blendFuncDestination", dictionary)); // color m_tStartColor.r = (float)atof(valueForKey("startColorRed", dictionary)); m_tStartColor.g = (float)atof(valueForKey("startColorGreen", dictionary)); m_tStartColor.b = (float)atof(valueForKey("startColorBlue", dictionary)); m_tStartColor.a = (float)atof(valueForKey("startColorAlpha", dictionary)); m_tStartColorVar.r = (float)atof(valueForKey("startColorVarianceRed", dictionary)); m_tStartColorVar.g = (float)atof(valueForKey("startColorVarianceGreen", dictionary)); m_tStartColorVar.b = (float)atof(valueForKey("startColorVarianceBlue", dictionary)); m_tStartColorVar.a = (float)atof(valueForKey("startColorVarianceAlpha", dictionary)); m_tEndColor.r = (float)atof(valueForKey("finishColorRed", dictionary)); m_tEndColor.g = (float)atof(valueForKey("finishColorGreen", dictionary)); m_tEndColor.b = (float)atof(valueForKey("finishColorBlue", dictionary)); m_tEndColor.a = (float)atof(valueForKey("finishColorAlpha", dictionary)); m_tEndColorVar.r = (float)atof(valueForKey("finishColorVarianceRed", dictionary)); m_tEndColorVar.g = (float)atof(valueForKey("finishColorVarianceGreen", dictionary)); m_tEndColorVar.b = (float)atof(valueForKey("finishColorVarianceBlue", dictionary)); m_tEndColorVar.a = (float)atof(valueForKey("finishColorVarianceAlpha", dictionary)); // particle size m_fStartSize = (float)atof(valueForKey("startParticleSize", dictionary)); m_fStartSizeVar = (float)atof(valueForKey("startParticleSizeVariance", dictionary)); m_fEndSize = (float)atof(valueForKey("finishParticleSize", dictionary)); m_fEndSizeVar = (float)atof(valueForKey("finishParticleSizeVariance", dictionary)); // position float x = (float)atof(valueForKey("sourcePositionx", dictionary)); float y = (float)atof(valueForKey("sourcePositiony", dictionary)); this->setPosition( ccp(x,y) ); m_tPosVar.x = (float)atof(valueForKey("sourcePositionVariancex", dictionary)); m_tPosVar.y = (float)atof(valueForKey("sourcePositionVariancey", dictionary)); // Spinning m_fStartSpin = (float)atof(valueForKey("rotationStart", dictionary)); m_fStartSpinVar = (float)atof(valueForKey("rotationStartVariance", dictionary)); m_fEndSpin= (float)atof(valueForKey("rotationEnd", dictionary)); m_fEndSpinVar= (float)atof(valueForKey("rotationEndVariance", dictionary)); m_nEmitterMode = atoi(valueForKey("emitterType", dictionary)); // Mode A: Gravity + tangential accel + radial accel if( m_nEmitterMode == kCCParticleModeGravity ) { // gravity modeA.gravity.x = (float)atof(valueForKey("gravityx", dictionary)); modeA.gravity.y = (float)atof(valueForKey("gravityy", dictionary)); // speed modeA.speed = (float)atof(valueForKey("speed", dictionary)); modeA.speedVar = (float)atof(valueForKey("speedVariance", dictionary)); const char * pszTmp = NULL; // radial acceleration pszTmp = valueForKey("radialAcceleration", dictionary); modeA.radialAccel = (pszTmp) ? (float)atof(pszTmp) : 0; pszTmp = valueForKey("radialAccelVariance", dictionary); modeA.radialAccelVar = (pszTmp) ? (float)atof(pszTmp) : 0; // tangential acceleration pszTmp = valueForKey("tangentialAcceleration", dictionary); modeA.tangentialAccel = (pszTmp) ? (float)atof(pszTmp) : 0; pszTmp = valueForKey("tangentialAccelVariance", dictionary); modeA.tangentialAccelVar = (pszTmp) ? (float)atof(pszTmp) : 0; } // or Mode B: radius movement else if( m_nEmitterMode == kCCParticleModeRadius ) { modeB.startRadius = (float)atof(valueForKey("maxRadius", dictionary)); modeB.startRadiusVar = (float)atof(valueForKey("maxRadiusVariance", dictionary)); modeB.endRadius = (float)atof(valueForKey("minRadius", dictionary)); modeB.endRadiusVar = 0; modeB.rotatePerSecond = (float)atof(valueForKey("rotatePerSecond", dictionary)); modeB.rotatePerSecondVar = (float)atof(valueForKey("rotatePerSecondVariance", dictionary)); } else { CCAssert( false, "Invalid emitterType in config file"); CC_BREAK_IF(true); } // life span m_fLife = (float)atof(valueForKey("particleLifespan", dictionary)); m_fLifeVar = (float)atof(valueForKey("particleLifespanVariance", dictionary)); // emission Rate m_fEmissionRate = m_uTotalParticles / m_fLife; // texture // Try to get the texture from the cache char *textureName = (char *)valueForKey("textureFileName", dictionary); std::string fullpath = CCFileUtils::fullPathFromRelativeFile(textureName, m_sPlistFile.c_str()); CCTexture2D *tex = NULL; if (strlen(textureName) > 0) { // set not pop-up message box when load image failed bool bNotify = CCFileUtils::getIsPopupNotify(); CCFileUtils::setIsPopupNotify(false); tex = CCTextureCache::sharedTextureCache()->addImage(fullpath.c_str()); // reset the value of UIImage notify CCFileUtils::setIsPopupNotify(bNotify); } if (tex) { this->m_pTexture = tex; } else { char *textureData = (char*)valueForKey("textureImageData", dictionary); CCAssert(textureData, ""); int dataLen = strlen(textureData); if(dataLen != 0) { // if it fails, try to get it from the base64-gzipped data int decodeLen = base64Decode((unsigned char*)textureData, (unsigned int)dataLen, &buffer); CCAssert( buffer != NULL, "CCParticleSystem: error decoding textureImageData"); CC_BREAK_IF(!buffer); int deflatedLen = ZipUtils::ccInflateMemory(buffer, decodeLen, &deflated); CCAssert( deflated != NULL, "CCParticleSystem: error ungzipping textureImageData"); CC_BREAK_IF(!deflated); image = new CCImage(); bool isOK = image->initWithImageData(deflated, deflatedLen); CCAssert(isOK, "CCParticleSystem: error init image with Data"); CC_BREAK_IF(!isOK); m_pTexture = CCTextureCache::sharedTextureCache()->addUIImage(image, fullpath.c_str()); } } CCAssert( this->m_pTexture != NULL, "CCParticleSystem: error loading the texture"); CC_BREAK_IF(!m_pTexture); this->m_pTexture->retain(); bRet = true; } } while (0); CC_SAFE_DELETE_ARRAY(buffer); CC_SAFE_DELETE_ARRAY(deflated); CC_SAFE_DELETE(image); return bRet; }
void CCParticleSystem::setRotatePerSecondVar(float degrees) { CCAssert( m_nEmitterMode == kCCParticleModeRadius, "Particle Mode should be Radius"); modeB.rotatePerSecondVar = degrees; }
// ParticleSystem - Properties of Gravity Mode void CCParticleSystem::setTangentialAccel(float t) { CCAssert( m_nEmitterMode == kCCParticleModeGravity, "Particle Mode should be Gravity"); modeA.tangentialAccel = t; }
void CCActionTween::startWithTarget(CCNode *pTarget) { CCAssert(dynamic_cast<CCActionTweenDelegate*>(pTarget), "target must implement CCActionTweenDelegate"); CCActionInterval::startWithTarget(pTarget); m_fDelta = m_fTo - m_fFrom; }
void CCLabelBMFont::createFontChars() { int nextFontPositionX = 0; int nextFontPositionY = 0; unsigned short prev = -1; int kerningAmount = 0; CCSize tmpSize = CCSizeZero; int longestLine = 0; unsigned int totalHeight = 0; unsigned int quantityOfLines = 1; unsigned int stringLen = m_sString.length(); if (0 == stringLen) { return; } for (unsigned int i = 0; i < stringLen - 1; ++i) { unsigned short c = m_sString[i]; if (c == '\n') { quantityOfLines++; } } totalHeight = m_pConfiguration->m_uCommonHeight * quantityOfLines; nextFontPositionY = -(m_pConfiguration->m_uCommonHeight - m_pConfiguration->m_uCommonHeight * quantityOfLines); for (unsigned int i= 0; i < stringLen; i++) { unsigned short c = m_sString[i]; CCAssert( c < kCCBMFontMaxChars, "LabelBMFont: character outside bounds"); if (c == '\n') { nextFontPositionX = 0; nextFontPositionY -= m_pConfiguration->m_uCommonHeight; continue; } kerningAmount = this->kerningAmountForFirst(prev, c); const ccBMFontDef& fontDef = m_pConfiguration->m_pBitmapFontArray[c]; CCRect rect = fontDef.rect; CCSprite *fontChar; fontChar = (CCSprite*)(this->getChildByTag(i)); if( ! fontChar ) { fontChar = new CCSprite(); fontChar->initWithBatchNodeRectInPixels(this, rect); this->addChild(fontChar, 0, i); fontChar->release(); } else { // reusing fonts fontChar->setTextureRectInPixels(rect, false, rect.size); // restore to default in case they were modified fontChar->setIsVisible(true); fontChar->setOpacity(255); } float yOffset = (float) (m_pConfiguration->m_uCommonHeight - fontDef.yOffset); fontChar->setPositionInPixels( ccp( nextFontPositionX + fontDef.xOffset + fontDef.rect.size.width / 2.0f + kerningAmount, (float) nextFontPositionY + yOffset - rect.size.height/2.0f ) ); // NSLog(@"position.y: %f", fontChar.position.y); // update kerning nextFontPositionX += m_pConfiguration->m_pBitmapFontArray[c].xAdvance + kerningAmount; prev = c; // Apply label properties fontChar->setIsOpacityModifyRGB(m_bIsOpacityModifyRGB); // Color MUST be set before opacity, since opacity might change color if OpacityModifyRGB is on fontChar->setColor(m_tColor); // only apply opaccity if it is different than 255 ) // to prevent modifying the color too (issue #610) if( m_cOpacity != 255 ) { fontChar->setOpacity(m_cOpacity); } if (longestLine < nextFontPositionX) { longestLine = nextFontPositionX; } } tmpSize.width = (float) longestLine; tmpSize.height = (float) totalHeight; this->setContentSizeInPixels(tmpSize); }