int CCLuaEngine::executeEventWithArgs(int nHandler, CCArray* pArgs) { if (NULL == pArgs) return 0; CCObject* pObject = NULL; CCInteger* pIntVal = NULL; CCString* pStrVal = NULL; CCDouble* pDoubleVal = NULL; CCFloat* pFloatVal = NULL; CCBool* pBoolVal = NULL; int nArgNums = 0; for (unsigned int i = 0; i < pArgs->count(); i++) { pObject = pArgs->objectAtIndex(i); if (NULL != (pIntVal = dynamic_cast<CCInteger*>(pObject))) { m_stack->pushInt(pIntVal->getValue()); nArgNums++; } else if (NULL != (pStrVal = dynamic_cast<CCString*>(pObject))) { m_stack->pushString(pStrVal->getCString()); nArgNums++; } else if (NULL != (pDoubleVal = dynamic_cast<CCDouble*>(pObject))) { m_stack->pushFloat(pDoubleVal->getValue()); nArgNums++; } else if (NULL != (pFloatVal = dynamic_cast<CCFloat*>(pObject))) { m_stack->pushFloat(pFloatVal->getValue()); nArgNums++; } else if (NULL != (pBoolVal = dynamic_cast<CCBool*>(pObject))) { m_stack->pushBoolean(pBoolVal->getValue()); nArgNums++; } else if(NULL != pObject) { m_stack->pushCCObject(pObject, "CCObject"); nArgNums++; } } return m_stack->executeFunctionByHandler(nHandler, nArgNums); }
void EnergyGauge::draw(){ //최대값기준으로 %로 환산한 너비값 CCFloat width = (currentValue.getValue() / maxValue.getValue())* (float)maxSize.width; //라인의 두께는 높이 glLineWidth(maxSize.height); //100% 일때는 Green if (currentValue.getValue() == maxValue.getValue()) { ccDrawColor4B(255, 255, 0, 255); } //그외에는 Red else ccDrawColor4B(255, 0, 0, 255); ccDrawLine(ccp(0,0), ccp(width.getValue(), 0)); // ccDrawLine(ccp(0, 0), ccp(width, 0)); }
ValueMap valueMapFromDictionary(CCDictionary * root) { assert(root != NULL); ValueMap map; CCDictElement * e = NULL; CCDICT_FOREACH(root, e) { CCObject * obj = e->getObject(); if (dynamic_cast<CCString *>(obj) != NULL) { CCString * str = (CCString *)obj; map[e->getStrKey()] = cocos2d::Value(str->getCString()); } else if (dynamic_cast<CCFloat *>(obj) != NULL) { CCFloat * val = (CCFloat *)obj; map[e->getStrKey()] = cocos2d::Value(val->getValue()); } else if (dynamic_cast<CCDouble *>(obj) != NULL) { CCDouble * val = (CCDouble *)obj; map[e->getStrKey()] = cocos2d::Value(val->getValue()); } else if (dynamic_cast<CCInteger *>(obj) != NULL) { CCInteger * val = (CCInteger *)obj; map[e->getStrKey()] = cocos2d::Value(val->getValue()); } else if (dynamic_cast<CCBool *>(obj) != NULL) { CCBool * val = (CCBool *)obj; map[e->getStrKey()] = cocos2d::Value(val->getValue()); } else if (dynamic_cast<CCDictionary *>(obj) != NULL) { CCDictionary * dict = (CCDictionary *)obj; map[e->getStrKey()] = cocos2d::Value(valueMapFromDictionary(dict)); } else if (dynamic_cast<CCArray *>(obj) != NULL) { CCArray * arr = (CCArray *)obj; map[e->getStrKey()] = cocos2d::Value(valueVectorFromArray(arr)); } }
void onOldNotificationFloat( Utils::BaseClass* pObject ) { //We use static cast for better performance CCFloat* pFloat = static_cast<CCFloat*>( pObject ); deliveredCount += pFloat->getValue(); }