void CCNodeAdornmentOverlayFader::initWithSprite( CCSprite* sprite ) { initWithSprite( sprite, kCCOpacityFull ); }
void CCNodeAdornmentOverlayFader::initWithSprite( CCSprite* sprite, CCOpacity opacity ) { initWithSprite( sprite, opacity, kDefaultFadeDuration ); }
ToggleButton::ToggleButton( Sprite2D* pOnImg, Sprite2D* pOffImg ) { for (int i = 0; i < 3; i++) mImg[i] = NULL; initWithSprite(pOnImg, pOffImg, NULL); }
void ProgressBarNode::SetProtoData( const CoreProto::Editor::ProgressBar& val ) { mProtoData = val; SetName(val.id()); CCSprite* sprite=new CCSprite(); sprite->autorelease(); FileSystemOrderItem* orderItem=ResourceManager::Instance().InitSprite(sprite,val.image(),val.size()); if (orderItem==NULL) { Log::LogErrorFormat("ProgressBarNode:Cannot find image:%s",val.image().file().name().c_str()); return; } if(!initWithSprite(sprite)) { Log::LogErrorFormat("Cannot init progress bar:%s",val.id().c_str()); return; } Point2F offset=orderItem->GetOffsetOrZero(); Size2F originalSize=orderItem->GetOriginalSizeOrZero(); Point2F newAnchorPoint=Point2F(val.anchor().x(),val.anchor().y()); if (offset!=Point2F::Zero) { CCSize contentSize=getContentSize(); newAnchorPoint= LayerEditor::CalculateAnchor(newAnchorPoint,offset,Size2F(contentSize.width,contentSize.height),Size2F(contentSize.width,contentSize.height)); } //setFlipX(val.isfilpx()); //setFlipY(val.isfilpy()); setZOrder(val.zorder()); setVisible(val.isvisible()); setAnchorPoint(ccp(newAnchorPoint.X,newAnchorPoint.Y)); if (val.has_scale()) { setScaleX(val.scale().x()); setScaleY(val.scale().y()); } else { setScale(1.f); } setRotation(val.rotation()); SetRenderFlag((RenderFlag)val.renderflag()); if (val.isproportionpoint()) { CCSize winSize= CCDirector::sharedDirector()->getWinSizeInPixels(); setPosition(ccp(val.position().x()*winSize.width,val.position().y()*winSize.height)); } else { setPosition(ccp(val.position().x(),val.position().y())); } setPercentage(100.f); setType((CCProgressTimerType)val.type()); CCPoint midPos = ccp(val.midpoint().x(),val.midpoint().y()); if (getType() == kCCProgressTimerTypeRadial) { midPos.x = Math::Clamp(midPos.x,0.001f,0.9999f); midPos.y = Math::Clamp(midPos.y,0.001f,0.9999f); } setMidpoint(midPos); setBarChangeRate(ccp(val.changerate().x(),val.changerate().y())); setTag(val.tag()); }
ToggleButton::ToggleButton( const char* pOnImg, const char* pOffImg, const char* pDisabledImg ) { for (int i = 0; i < 3; i++) mImg[i] = NULL; initWithSprite(Sprite2D::create(pOnImg), Sprite2D::create(pOffImg), Sprite2D::create(pDisabledImg)); }