void HSBalloonConfig::SaveBallonConfig() { HSAssert(m_pBalloonTestInfo,""); string path = CCFileUtils::sharedFileUtils()->getWriteablePath(); path += "ballon.config"; remove(path.c_str()); FILE* pFile = NULL; HS_fopen(pFile,path.c_str(),"w"); HSAssert(pFile,""); fseek( pFile, 0, SEEK_SET ); fwrite(m_pBalloonTestInfo,sizeof(BalloonTestInfo),1,pFile); fclose(pFile); }
void HSShowEndurance::Call_PerSecondSelector() { map<int,CCProgressTimer*>::iterator it; it = m_enduranceMap.find(HSShowEndurance::S_CURRENT_OPERATION_ENDURANCE_INDEX); if(it != m_enduranceMap.end()) { it->second->setPercentage(m_pTimeLabel->GetPastTimeRatio() * 100.f); for (int i = HSShowEndurance::S_CURRENT_OPERATION_ENDURANCE_INDEX - 1; i > 0; --i) { it = m_enduranceMap.find(i); if(it != m_enduranceMap.end()) { it->second->setPercentage(100.f); } } for(int i = HSShowEndurance::S_CURRENT_OPERATION_ENDURANCE_INDEX + 1;i <= HSShowEndurance::S_C_ENDURANCE_COUNT;++i) { it = m_enduranceMap.find(i); if(it != m_enduranceMap.end()) { it->second->setPercentage(0); } } }else{ HSAssert(false, "操作的体力不存在"); } }
b2Body* HSBalloonSprite::CreateBody(b2World* world ) { HSAssert(world,"world"); m_pWorld = world; b2BodyDef bodyDef; //bodyDef.type = b2_dynamicBody; bodyDef.type = b2_staticBody; bodyDef.bullet = true; CCSize texturSize = this->getTexture()->getContentSize(); bodyDef.position.Set(HS_VALUE_B2V(texturSize.width),HS_VALUE_B2V(texturSize.height)); b2Body *body = world->CreateBody(&bodyDef); HSBox2dShapeCache::sharedGB2ShapeCache()->addFixturesToBody(body,"animal_1"); body->SetUserData(this); body->SetAwake(false); body->SetSleepingAllowed(true); body->SetBullet(false); b2Fixture* fixture = body->GetFixtureList(); while(fixture) { fixture->SetRestitution(HSFormula::TanXiang()); fixture=fixture->GetNext(); } //this->setVisible(false); return body; }
void HSPropIconInterface::Call_CDEnd(CCNode* pProgress) { pProgress->getParent()->removeChild(pProgress); HSAssert(m_pMenuItem ,""); m_pMenuItem->setEnabled(true); }
static GString* cb_on_change(HSAttribute* attr) { int idx = attr - g_settings_object->attributes; HSAssert (idx >= 0 || idx < LENGTH(g_settings)); if (g_settings[idx].on_change) { g_settings[idx].on_change(); } return NULL; }
void HSGameGuide::Resume(CCNode* pNode) { #define HS_GameGuide_Tag 0x78956 HSAssert(pNode,""); this->setVisible(false); pNode->addChild(this,HS_GameGuide_Tag,HS_GameGuide_Tag); this->Run(this->GetCurrentStep() + 1 ); this->setVisible(true); }
void HSGameGuide::DrawRound( const GameGuide_Guide& guide ) { return; HSAssert(m_pShape,""); const int MAXVERTCOUNT = 100; ccColor4F green = {0, 1, 0, 1}; float fRadius = guide.w() / 2.f; float coef = 2.f * (float)M_PI/ MAXVERTCOUNT; CCPoint circle[MAXVERTCOUNT]; for(unsigned int i = 0;i <MAXVERTCOUNT; i++) { float rads = i * coef; circle[i].x = fRadius * cosf(rads); circle[i].y = fRadius * sinf(rads); } //CCPoint pos = ccp(guide.modepos().x(),guide.modepos().y()); m_pShape->drawPolygon(circle, MAXVERTCOUNT, green, 0, green); //m_pShape->setPosition(pos); //HSTool::SetPointScale(pos); /** CCSprite* pHand = CCSprite::create("Image/hand.png"); pHand->setAnchorPoint(ccp(0.0f,1.0f)); pHand->setPosition(pos); this->addChild(pHand); m_nodeList.push_back(pHand);*/ //if (m_currentGuide.isintercepttouch()) { if (m_currentGuide.isintercepttouch()) { this->AddDefaultEvent(); }else{ CCPoint pos = ccp(guide.modepos().x(),guide.modepos().y()); float lx = pos.x - guide.w() / 2.f; float ly = pos.y - guide.h() / 2.f; CCRect ccRect(lx,ly,guide.w(),guide.h()); m_ListerEvent.SetRect(ccRect,pos); } } }
bool HSBalloonSprite::InitWithFile( const char* fileName,b2World* world ,int id) { HSAssert(world,""); m_id = id; m_pWorld = world; bool isInitOK = this->initWithFile(fileName); //bool isInitOK = this->initWithSpriteFrame(pBalloonSpriteFrame); this->setPTMRatio(HS_PTM_RATIO); b2Body *body = this->CreateBody(world); this->setB2Body(body); return !isInitOK || !body ? false : true; }
bool HSBalloonSprite::InitWithTexture(CCTexture2D* texture,b2World* world,int id) { HSAssert(world,""); m_id = id; m_pWorld = world; bool isInitOK = this->initWithTexture(texture); this->setPTMRatio(HS_PTM_RATIO); b2Body *body = this->CreateBody(world); this->setB2Body(body); // CCLabelTTF* id_TTF = CCLabelTTF::create(CCString::createWithFormat("%d",id)->getCString(),"",32); // this->addChild(id_TTF); return !isInitOK || !body ? false : true; }
static void cb_read_compat(void* data, GString* output) { SettingsPair* sp = (SettingsPair*)data; const char* cmd[] = { "attr_get", sp->value.compat.read, NULL }; HSAssert(0 == hsattribute_get_command(LENGTH(cmd) - 1, cmd, output)); }