コード例 #1
0
ファイル: PubSprite.cpp プロジェクト: wanguolin/FreeValley
void PubSprite::semiselected()
{
    if (pub_sprite_ == NULL)
        return;
    const float kDisplayWidth = 354.0 * gScale;
    const float kDisplayHeight = 530.0 * gScale;
    Rect inset_rect = CCRectMake(38, 29, 1, 1);
    Rect full_rect = CCRectMake(0, 0, 74, 284);
    pub_sprite_->removeAllChildren();

    /* add the sun state */
    Sprite *sun = Sprite::create("main_screen/sun_semi.png");
    const float kSunOffsetY = 317;
    if (gScale == 1.0)
        sun->setPosition(ccp(kDisplayWidth*2/3, kDisplayHeight*2/3+kSunOffsetY));
    else
        sun->setPosition(ccp(kDisplayWidth, kDisplayHeight+kSunOffsetY));

    sun->setTag(2);
    pub_sprite_->addChild(sun, 1);
    /* add the white border*/
    const float kBorderWidth = 480;
    const float kBorderHeight = 706;
    const float kBorderX = 226;
    const float kBorderY = 336;
    Scale9Sprite *yborder = Scale9Sprite::create("main_screen/border_selected.png", full_rect, inset_rect); 
    yborder->setPreferredSize(CCSizeMake(kBorderWidth, kBorderHeight));
    yborder->setPosition(ccp(kBorderX, kBorderY));
    yborder->setTag(2);
    pub_sprite_->addChild(yborder);
}
コード例 #2
0
ファイル: PubSprite.cpp プロジェクト: wanguolin/FreeValley
void PubSprite::unseleted()
{
    if (pub_sprite_ == NULL)
        return;
    const float kDisplayWidth = 354.0 * gScale;
    const float kDisplayHeight = 530.0 * gScale;
    Rect inset_rect = CCRectMake(11, 13, 1, 1);
    Rect full_rect = CCRectMake(0, 0, 22, 23);
    pub_sprite_->removeAllChildren();
    /* add the cloud state */
    Sprite *cloud = Sprite::create("main_screen/cloud_unselected.png");
    const float kCloudOffsetY = 317;
    if (gScale == 1.0)
        cloud->setPosition(ccp(kDisplayWidth*2/3, kDisplayHeight*2/3+kCloudOffsetY));
    else
        cloud->setPosition(ccp(kDisplayWidth, kDisplayHeight+kCloudOffsetY));
    cloud->setTag(1);
    pub_sprite_->addChild(cloud, 1);

    /* add the white border*/
    const float kBorderWidth = 460;
    const float kBorderHeight = 685;
    const float kBorderX = 226;
    const float kBorderY = 336;
    Scale9Sprite *wborder = Scale9Sprite::create("main_screen/border_unselected.png", full_rect, inset_rect); 
    wborder->setPreferredSize(CCSizeMake(kBorderWidth, kBorderHeight));
    wborder->setPosition(ccp(kBorderX, kBorderY));
    wborder->setTag(1);
    pub_sprite_->addChild(wborder);
}
コード例 #3
0
ファイル: PubSprite.cpp プロジェクト: wanguolin/FreeValley
void PubSprite::selected()
{
    if (pub_sprite_ == NULL)
        return;
    const float kDisplayWidth = 354.0 * gScale;
    const float kDisplayHeight = 530.0 * gScale;
    Rect inset_rect = CCRectMake(38, 29, 1, 1);
    Rect full_rect = CCRectMake(0, 0, 74, 284);
    pub_sprite_->removeAllChildren();

    /** 
     * add the sun state 
     */
    Sprite *sun = Sprite::create("main_screen/sun_selected.png");

    /* gScale is 1 means 1080p, so 2/3 is a fixed number to get the right position */
    const float kSunOffsetY = 317;
    if (gScale == 1.0)
        sun->setPosition(ccp(kDisplayWidth*2/3, kDisplayHeight*2/3+kSunOffsetY));
    else
        sun->setPosition(ccp(kDisplayWidth, kDisplayHeight+kSunOffsetY));
    sun->setTag(2);
    pub_sprite_->addChild(sun, 1);

    /** 
     * add the white border
     */
    const float kBorderWidth = 480;
    const float kBorderHeight = 706;
    const float kBorderX = 226;
    const float kBorderY = 336;
    Scale9Sprite *yborder = Scale9Sprite::create("main_screen/border_selected.png", full_rect, inset_rect); 
    yborder->setPreferredSize(CCSizeMake(kBorderWidth, kBorderHeight));
    yborder->setPosition(ccp(kBorderX, kBorderY));
    yborder->setTag(2);
    pub_sprite_->addChild(yborder);
    
    if (pub_title_ != NULL){
        int size = 36;
        if (strlen(pub_title_) > 35){
            size = 32;
        }
        LabelTTF *title= LabelTTF::create(pub_title_, "Arial", size);
        CCLog("title %s, length %d", pub_title_, strlen(pub_title_));
        title->setFontFillColor(ccc3(255, 255, 0));
        pub_sprite_->addChild(title);
        const float kTitleOffsetX = 10;
        const float kTitleOffsetY = 60;
        if (gScale == 1.0)
            title->setPosition(kDisplayWidth*2/3-kTitleOffsetX, kTitleOffsetY);
        else
            title->setPosition(kDisplayWidth-kTitleOffsetX, kTitleOffsetY);
    }
}
コード例 #4
0
ファイル: PubSprite.cpp プロジェクト: wanguolin/FreeValley
void PubSprite::showpubUnselect()
{
    pub_sprite_->removeAllChildren();

    const float kDisplayWidth = 290.0 * gScale;
    const float kDisplayHeight = 544.0 * gScale;
    Rect inset_rect = CCRectMake(12, 12, 1, 1);
    Rect full_rect = CCRectMake(0, 0, 23, 73);

    /* add the cloud state */
    Sprite *cloud = Sprite::create("main_screen/cloud_unselected.png");
    const float kCloudOffsetY = 295;
    const float kCloudOffsetX = 55;
    if (gScale == 1.0)
        cloud->setPosition(ccp(kDisplayWidth*2/3+kCloudOffsetX, kDisplayHeight*2/3+kCloudOffsetY));
    else
        cloud->setPosition(ccp(kDisplayWidth+kCloudOffsetX, kDisplayHeight+kCloudOffsetY));
    cloud->setTag(1);
    pub_sprite_->addChild(cloud, 1);
    /** 
     * add the white border
     */
    const float kBorderWidth = 460;
    const float kBorderHeight = 730;
    const float kBorderX = 225;
    const float kBorderY = 310;
    Scale9Sprite *wborder = Scale9Sprite::create("showlist/border_unselected.png", full_rect, inset_rect); 
    wborder->setPreferredSize(CCSizeMake(kBorderWidth, kBorderHeight));
    wborder->setPosition(ccp(kBorderX, kBorderY));
    wborder->setTag(2);
    pub_sprite_->addChild(wborder);

    if (pub_title_ != NULL){
        int size = 36;
        if (strlen(pub_title_) > 30){
            size = 32;
        }
        LabelTTF *title= LabelTTF::create(pub_title_, "Arial", size);
        /** the color is blue */
        title->setFontFillColor(ccc3(67, 155, 203));
        pub_sprite_->addChild(title);
        const float kTitleOffsetX = 20;
        const float kTitleOffsetY = 20;
        if (gScale == 1.0)
            title->setPosition(kDisplayWidth*2/3+kTitleOffsetX, -kTitleOffsetY);
        else
            title->setPosition(kDisplayWidth+kTitleOffsetX, -kTitleOffsetY);
    }
}
コード例 #5
0
ファイル: PubSprite.cpp プロジェクト: wanguolin/FreeValley
void PubSprite::showpubSelect()
{
    pub_sprite_->removeAllChildren();
    const float kDisplayWidth = 290.0 * gScale;
    const float kDisplayHeight = 544.0 * gScale;
    Sprite *sun = Sprite::create("main_screen/sun_semi.png");
    const float kSunOffsetY = 315;
    const float kSunOffsetX = 35;
    if (gScale == 1.0)
        sun->setPosition(ccp(kDisplayWidth*2/3+kSunOffsetX, kDisplayHeight*2/3+kSunOffsetY));
    else
        sun->setPosition(ccp(kDisplayWidth+kSunOffsetX, kDisplayHeight+kSunOffsetY));

    sun->setTag(2);
    pub_sprite_->addChild(sun, 1);
    Rect inset_rect = CCRectMake(30, 27, 1, 1);
    Rect full_rect = CCRectMake(0, 0, 60, 120);
    const float kBorderWidth = 500;
    const float kBorderHeight = 775;
    const float kBorderX = 225;
    const float kBorderY = 298;
    Scale9Sprite *yborder = Scale9Sprite::create("showlist/border_selected.png", full_rect, inset_rect); 
    yborder->setPreferredSize(CCSizeMake(kBorderWidth, kBorderHeight));
    yborder->setPosition(ccp(kBorderX, kBorderY));
    yborder->setTag(2);
    pub_sprite_->addChild(yborder);
    
    if (pub_title_ != NULL){
        int size = 46;
        if (strlen(pub_title_) > 38){
            size = 32;
        }
        LabelTTF *title= LabelTTF::create(pub_title_, "Arial", size);
        /** the color is blue */
        title->setFontFillColor(ccc3(67, 155, 203));
        pub_sprite_->addChild(title);
        const float kTitleOffsetX = 20;
        const float kTitleOffsetY = 30;
        if (gScale == 1.0)
            title->setPosition(kDisplayWidth*2/3+kTitleOffsetX, -kTitleOffsetY);
        else
            title->setPosition(kDisplayWidth+kTitleOffsetX, -kTitleOffsetY);
    }
}