本文整理汇总了C++中CCString::floatValue方法的典型用法代码示例。如果您正苦于以下问题:C++ CCString::floatValue方法的具体用法?C++ CCString::floatValue怎么用?C++ CCString::floatValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCString
的用法示例。
在下文中一共展示了CCString::floatValue方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parseInternalProperties
void CCTMXLayer::parseInternalProperties()
{
// if cc_vertex=automatic, then tiles will be rendered using vertexz
CCString *vertexz = propertyNamed("cc_vertexz");
if( vertexz )
{
// If "automatic" is on, then parse the "cc_alpha_func" too
if( vertexz->m_sString == "automatic" )
{
m_bUseAutomaticVertexZ = true;
CCString *alphaFuncVal = propertyNamed("cc_alpha_func");
float alphaFuncValue = 0.0f;
if (alphaFuncVal != NULL)
{
alphaFuncValue = alphaFuncVal->floatValue();
}
setShaderProgram(CCShaderCache::sharedShaderCache()->programForKey(kCCShader_PositionTextureColorAlphaTest));
GLint alphaValueLocation = glGetUniformLocation(getShaderProgram()->getProgram(), kCCUniformAlphaTestValue);
// NOTE: alpha test shader is hard-coded to use the equivalent of a glAlphaFunc(GL_GREATER) comparison
getShaderProgram()->setUniformLocationWith1f(alphaValueLocation, alphaFuncValue);
}
else
{
m_nVertexZvalue = vertexz->intValue();
}
}
}
示例2: getFloatParameter
bool CComponentParameter::getFloatParameter(const string& name, float& value)
{
CCString* str = dynamic_cast<CCString*>(parameters_->objectForKey(name));
if (!str)
{
return false;
}
value = str->floatValue();
return true;
}
示例3: doCallback
bool CallbackExplode::doCallback(GameObject * aGameObject,CCDictionary * dic,float dt) {
if (dic && aGameObject) {
//获得效果本身影响的范围
CCDictionary * property = (CCDictionary *)aGameObject->getValue(KStrProperty);
CCString * atkStr = (CCString *)property->objectForKey(KStrATK);
CCString * atkRangeStr = (CCString *)property->objectForKey(KStrATK_RANGE);
float atk_range_org = (atkRangeStr?atkRangeStr->floatValue():0) * 0.5;
float atk = atkStr? atkStr->floatValue() : 0;
//获得对应的效果播放的中心点
CCDictionary * pDict=(CCDictionary *)dic->objectForKey(KStrPosition);
CCString * paramStr=(CCString *)dic->objectForKey(KStrParam);
float scale = !paramStr ? 1.0 : paramStr->floatValue();
float atk_range = scale * atk_range_org;
CCPoint p = GameObject::dict2Point(pDict);
GameModle * _sharedInstance = GameModle::sharedInstance();
CCDictionary * objects = _sharedInstance->gameObjectsDict();
CCDictElement * pDictElement = NULL;
CCDICT_FOREACH(objects, pDictElement){
int32_t classid=pDictElement->getIntKey();
if(KNPCTypeId == GameObject::typeIdOfClassId(classid)){
CCSet * set=(CCSet*)pDictElement->getObject();
CCSetIterator iter;
for (iter = set->begin(); iter != set->end(); ++iter)
{
GameObject * tmp=(GameObject *)(*iter);
if (tmp->isActive()) {
float r = tmp->getContentSize().width * 0.5;
//检测可以攻击到泡泡
if(GameObject::isCircleContact(p,atk_range,tmp->getPosition(),r)){
//处理进入到攻击范围的泡泡
handleExplode(tmp,NULL,atk,aGameObject);
}
}
}
}
}
示例4: floatValueFromDictionary
float32 floatValueFromDictionary(CCDictionary * dict, const string & key)
{
CCString * result = dynamic_cast<CCString *>(dict->objectForKey(key));
if (result != NULL)
{
return result->floatValue();
}
else
{
return 0.0f;
}
}
示例5: initWithDictionary
// SFEaseRateAction
bool SFEaseRateAction::initWithDictionary(CCDictionary * pDict)
{
if (!SFActionEase::initWithDictionary(pDict))
{
CNLog("error");
return false;
}
CCString * pRate = (CCString *)pDict->objectForKey("Rate");
m_fRate = pRate ? pRate->floatValue() : 0;
return true;
}
示例6:
YHAnimationFrameDefiner::YHAnimationFrameDefiner(CCDictionary * dict)
{
// index
CCString * strIndex = dynamic_cast<CCString *>(dict->objectForKey("Index"));
m_index = strIndex->uintValue();
// Delay units
CCString * strDelayUnits = dynamic_cast<CCString *>(dict->objectForKey("DelayUnits"));
m_delayUnit = strDelayUnits != NULL ? strDelayUnits->floatValue() : 1.0f;
// UserData
m_userInfo = dynamic_cast<CCDictionary *>(dict->objectForKey("UserInfo"));
CC_SAFE_RETAIN(m_userInfo);
}
示例7: CatchBug
void User::CatchBug(Bug* bug)
{
string x = bug->getId();
if (bugsCatched->objectForKey(x) != NULL)
{
CCString* count = (CCString*)bugsCatched->valueForKey(x);
int increase = count->floatValue() + 1;
CCString* add = CCString::create(ConvertInt(increase));
bugsCatched->setObject(add,x);
}
else
{
CCString* count = CCString::create("1");
bugsCatched->setObject(count,x);
}
}
示例8: parseInternalProperties
void CCTMXLayer::parseInternalProperties()
{
// if cc_vertex=automatic, then tiles will be rendered using vertexz
CCString *vertexz = propertyNamed("cc_vertexz");
if (vertexz)
{
// If "automatic" is on, then parse the "cc_alpha_func" too
if (vertexz->m_sString == "automatic")
{
m_bUseAutomaticVertexZ = true;
CCString *alphaFuncVal = propertyNamed("cc_alpha_func");
float alphaFuncValue = 0.0f;
if (alphaFuncVal != NULL)
{
alphaFuncValue = alphaFuncVal->floatValue();
}
setShaderProgram(CCShaderCache::sharedShaderCache()->programForKey(kCCShader_PositionTextureColorAlphaTest));
GLint alphaValueLocation = glGetUniformLocation(getShaderProgram()->getProgram(), kCCUniformAlphaTestValue);
// NOTE: alpha test shader is hard-coded to use the equivalent of a glAlphaFunc(GL_GREATER) comparison
getShaderProgram()->setUniformLocationWith1f(alphaValueLocation, alphaFuncValue);
}
else
{
m_nVertexZvalue = vertexz->intValue();
}
}
// if cc_zorder=automatic, then tiles will be rendered using in row order from top to bottom
CCString *zorder = propertyNamed("useZOrderbyY");
if (zorder)
{
m_bUseZOrderByY = true;
// delete AtlasIndexArray as we no longer can use quads in this mode
// all tiles will be instantiated as sprites
if (m_pAtlasIndexArray)
{
ccCArrayFree(m_pAtlasIndexArray);
m_pAtlasIndexArray = NULL;
}
}
}
示例9: compareVersion
void ResourceManager::compareVersion()
{
//(1)取版本描述文件内的版本号
CCString* versionStr = CCString::createWithContentsOfFile(RMVersionFile);
serverResourceVersion = versionStr->floatValue();
//(3)比对
versionLatest = (localVersion >= serverResourceVersion);
if (this->delegate) {
this->delegate->onVersionCheckCompleted(false);
}
#if ScriptType ==1
if (this->scriptDelegate) {
CCArray* params = CCArray::createWithObject(CCBool::create(versionLatest));
CCArray* paramTypes = CCArray::createWithObject(CCString::create("CCBool"));
LuaUtil::executePeertableFunction(this->scriptDelegate, "onVersionCheckCompleted", params, paramTypes, false);
}
#endif
}
示例10: stopUpdateItemDegree
//=============================================================
//=============================================================
void CC3DCircleListLayer::moveToCenter(CCButton* pButton,bool bActionFlag)
{
if(!pButton)
return;
stopUpdateItemDegree();
CCString* pFOldDegree = (CCString*)pButton->getUserData();
float fOldDegree = pFOldDegree->floatValue();
m_fLastMoveDegree = 1.5*M_PI - fOldDegree;
if(m_fLastMoveDegree > M_PI)
{
m_fLastMoveDegree = - (2*M_PI - m_fLastMoveDegree);
}
if(bActionFlag)
{
schedule(schedule_selector(CC3DCircleListLayer::updateItemDegree));
}
else
{
refreshItemWithMoveDegree(m_fLastMoveDegree);
}
}
示例11: getContentSize
//=============================================================
//=============================================================
void CC3DCircleListLayer::refreshItemWithMoveDegree(float fMoveDegree)
{
float fMoveX = getContentSize().width*0.5;
float fMoveY = getContentSize().height*0.5;
float fScaleMax = 1;
float fScaleMin = 0.5;
int zOrderMax = 1000;
// float fCameraDegreeMax = 45;
// float fCameraDegreeMin = 0;
for(int i=0;i<m_pButtonArray->count();i++)
{
CCButton* pButton = (CCButton*)m_pButtonArray->objectAtIndex(i);
CCString* pFOldDegree = (CCString*)pButton->getUserData();
float fOldDegree = pFOldDegree->floatValue();
fOldDegree = fabsf(fOldDegree);
float fCurDegree = fOldDegree + fMoveDegree;
if(fCurDegree < 0)
{
fCurDegree = 2*M_PI - fabsf(fCurDegree);
}
int nCircleCount = (int)fCurDegree/(2*M_PI);
fCurDegree = fCurDegree - nCircleCount*(2*M_PI);
//=============================================================
//=============================================================
delete pFOldDegree;
CCString* pString = new CCString();
pString->initWithFormat("%f",fabs(fCurDegree));
pButton->setUserData(pString);
//=============================================================
//=============================================================
//
//
//
//=============================================================
//=============================================================
float fCircleX = m_fEllipseA * cosf(fCurDegree);
float fCircleY = m_fEllipseB * sinf(fCurDegree);
fCircleX += fMoveX;
fCircleY += fMoveY;
CCPoint buttonPos = ccp(fCircleX,fCircleY);
pButton->setPosition(buttonPos);
//=============================================================
//=============================================================
//
//
//
//=============================================================
//=============================================================
float fScaleDegree = fCurDegree - M_PI_2;
float fScalePercent = (1-cosf(fScaleDegree))/2.0;
float fScale = fScaleMin + (fScaleMax - fScaleMin)*fScalePercent;
pButton->setScale(fScale);
int nOrder = zOrderMax * fScalePercent + 1;
pButton->setZOrder(nOrder);
//=============================================================
//=============================================================
m_pSelectedButton = getSelectedButton();
if(m_pSelectedButton)
{
if(m_pDelegate)
{
int nIndex = m_pSelectedButton->getTag();
m_pDelegate->onCC3DCircleListLayerSelectIndex(nIndex);
}
}
// //=============================================================
// //camera
// //=============================================================
// int flagMove = 1;
// if(buttonPos.x > getContentSize().width*0.5)
// {
// flagMove = 1;
// }
// else
// {
// flagMove = -1;
// }
// float fCameraDegree = fCameraDegreeMin + (fCameraDegreeMax - fCameraDegreeMin)*(1-fScalePercent);
// fCameraDegree *= -flagMove;
// float radians = (float)CC_DEGREES_TO_RADIANS(fCameraDegree);
// float fSin = sinf(radians) * CCCamera::getZEye();
// CCCamera* pCamera = pButton->getCamera();
// pCamera->setCenterXYZ(fSin, 0, 0);
// //=============================================================
// //=============================================================
}
}