Example #1
0
void EasyEffect::setFadeEffect(float fTime,fadeTYPE fType)
{
	CCLayerColor* clrLayer	= (CCLayerColor*)CCDirector::sharedDirector()->getRunningScene()->getChildByTag(99);
	if(clrLayer == NULL)
		return;

	switch(fType)
	{
	case white_FADE_IN:
		{
			clrLayer->initWithColor(Color4B(255,255,255,255));
			CCActionInterval* whtFadeOut=CCFadeTo::create(fTime,0);
			clrLayer->runAction(whtFadeOut);
			break;
		}
	case white_FADE_OUT:
		{
			clrLayer->initWithColor(ccc4(255,255,255,0));
			CCActionInterval* whtFadeIn=CCFadeTo::create(fTime,255);
			clrLayer->runAction(whtFadeIn);
			break;
		}
	case black_FADE_IN:
		{
			clrLayer->initWithColor(ccc4(0,0,0,255));
			CCActionInterval* blkFadeOut=CCFadeTo::create(fTime,0);
			clrLayer->runAction(blkFadeOut);
			break;
		}
	case black_FADE_OUT:
		{
			clrLayer->initWithColor(ccc4(0,0,0,0));
			CCActionInterval* blkFadeIn=CCFadeTo::create(fTime,255);
			clrLayer->runAction(blkFadeIn);
			break;
		}
	case black_FADE_HOLD:
		{
			clrLayer->initWithColor(ccc4(0,0,0,255));
		}
		break;
	case black_FADE_OUTIN:
		{
			CCActionInterval* blkFadeOut=CCFadeTo::create(fTime,255);
			CCActionInterval* blkFadeIn=CCFadeTo::create(fTime,0);
			CCActionInterval*	seq	= CCSequence::create(blkFadeOut,blkFadeIn,NULL);
			clrLayer->runAction(seq);
		}
		break;
	}
}
Example #2
0
CCLayerColor * CCLayerColor::layerWithColor(const ccColor4B& color)
{
    CCLayerColor * pLayer = new CCLayerColor();
    if(pLayer && pLayer->initWithColor(color))
    {
        pLayer->autorelease();
        return pLayer;
    }
    CC_SAFE_DELETE(pLayer);
    return NULL;
}
Example #3
0
CCLayerColor * CCLayerColor::create(const ccColor4B& color, GLfloat width, GLfloat height)
{
    CCLayerColor * pLayer = new CCLayerColor();
    if( pLayer && pLayer->initWithColor(color,width,height))
    {
        pLayer->autorelease();
        return pLayer;
    }
    CC_SAFE_DELETE(pLayer);
    return NULL;
}
LoginRegDialog::LoginRegDialog(CCNode *parent,const ccColor4B &color)
{
    clear();
    if(color.r == 0 && color.g == 0 && color.b == 0 && color.a == 0){
    }else if(parent){
        CCLayerColor *realparent = CCLayerColor::create();
        realparent->initWithColor(color);
        parent->addChild(realparent);
        parent = realparent;
    }
    m_edgeSize = 20;
    m_theme = "default";
    m_bg = "dialog";
    CCSize size = CCDirector::sharedDirector()->getWinSize();
    float width = size.width < size.height ? size.width : size.height;
    width *= 0.9;
    float height = width * 0.8;
    setAnchoredSize(width,height);
    setTouchPriority(HighPriority);

    BasNodeAction *moveIn = UiNodeActionFactory::getInstance()->getMoveActionByName("movein");
    BasNodeAction *moveOut = UiNodeActionFactory::getInstance()->getMoveActionByName("moveout");
    moveIn->setEaseType(uilib::EaseSineInOut);
    moveIn->setMoveInType(uilib::ScaleIn);
    moveOut->setEaseType(uilib::EaseSineInOut);
    moveOut->setMoveOutType(uilib::ScaleYOut);
    moveOut->setActionTime(0.2);
    moveOut->setFinishCB(this,callfuncN_selector(LoginRegDialog::onMoveOutFinished));
    this->setMoveinAction(moveIn);
    this->setMoveoutAction(moveOut);
    if(parent){
        parent->addChild(this);
        this->setAnchorPoint(ccp(0.5,0.5));
        this->setPosition(ccp(size.width / 2,size.height / 2));
    }
}
// on "init" you need to initialize your instance
bool SpriteDragger::init()
{
    //////////////////////////////
    // 1. super init first
    if ( !CCLayer::init() )
    {
        return false;
    }
    
    this->setTouchEnabled(true);
    
    /////////////////////////////
    // 2. add a menu item with "X" image, which is clicked to quit the program
    //    you may modify it.
    
    // add a "close" icon to exit the progress. it's an autorelease object
    CCMenuItemImage *pCloseItem = CCMenuItemImage::create(
                                                          "CloseNormal.png",
                                                          "CloseSelected.png",
                                                          this,
                                                          menu_selector(SpriteDragger::menuCloseCallback) );
    pCloseItem->setPosition( ccp(CCDirector::sharedDirector()->getWinSize().width - 20, 20) );
    
    // create menu, it's an autorelease object
    CCMenu* pMenu = CCMenu::create(pCloseItem, NULL);
    pMenu->setPosition( CCPointZero );
    this->addChild(pMenu, 2);
    
    //color layer
    CCLayerColor* colorLayer = new CCLayerColor;
    colorLayer->initWithColor( ccc4(255, 255, 255, 255) );
    this->addChild(colorLayer, 1);
    
    CCSize winSize = CCDirector::sharedDirector()->getWinSize();
    this->sprite = new CCSprite;
    this->sprite->initWithFile("Sprite.png");
    this->sprite->setPosition(ccp(winSize.width / 2.0f, winSize.height / 2.0f ));
    this->sprite->setAnchorPoint(ccp(0.5f, 0.55f));
    this->addChild(this->sprite);
    
    /*
    /////////////////////////////
    // 3. add your codes below...
    
    // add a label shows "Hello World"
    // create and initialize a label
    CCLabelTTF* pLabel = CCLabelTTF::create("Hello World SpriteDragger", "Thonburi", 34);
    
    // ask director the window size
    CCSize size = CCDirector::sharedDirector()->getWinSize();
    
    // position the label on the center of the screen
    pLabel->setPosition( ccp(size.width / 2, size.height - 20) );
    
    // add the label as a child to this layer
    this->addChild(pLabel, 1);
    
    
    
    // add "HelloWorld" splash screen"
    CCSprite* pSprite = CCSprite::create("HelloWorld.png");
    
    // position the sprite on the center of the screen
    pSprite->setPosition( ccp(size.width/2, size.height/2) );
    
    // add the sprite as a child to this layer
    this->addChild(pSprite, 0);
    */
    
    return true;
}
// on "init" you need to initialize your instance
bool MainMenuScene::init()
{
    // Parent
    CCLayerColor *layer = CCLayerColor::create();
    layer->initWithColor(ccc4(255, 255, 255, 255), VisibleRect::right().x , VisibleRect::top().y);
    layer->setPosition(VisibleRect::center());
    layer->setAnchorPoint(ccp(0.5f, 0.5f));
    layer->ignoreAnchorPointForPosition(false);
    addChild(layer, 0);
    
    CCSprite *fondo = CCSprite::create("fondo.png");
    fondo->setPosition(VisibleRect::center());
    layer->addChild(fondo);
    
    // 1st Son
    CCLayerColor *upperLayer = CCLayerColor::create();
    upperLayer->setContentSize(ccp(VisibleRect::right().x , VisibleRect::top().y/2));
    //upperLayer->initWithColor(ccc4(120, 120, 120, 120), VisibleRect::right().x , VisibleRect::top().y/2);
    upperLayer->setPosition(ccp(VisibleRect::left().x, VisibleRect::center().y));
    upperLayer->setAnchorPoint(ccp(0,0));
    upperLayer->ignoreAnchorPointForPosition(false);
    layer->addChild(upperLayer, 0);
    
    CCSprite *spriteLogo = CCSprite::create("logo_opciones.png");
    spriteLogo->setPosition(ccp(layer->getPosition().x, layer->getPosition().y/2));
    upperLayer->addChild(spriteLogo);
    
    // 2nd Son
    CCLayerColor *lowerLayer = CCLayerColor::create();
    lowerLayer->setContentSize(ccp(VisibleRect::right().x , VisibleRect::top().y/2));
    //lowerLayer->initWithColor(ccc4(200, 200, 200, 200), VisibleRect::right().x , VisibleRect::top().y/2);
    lowerLayer->setPosition(ccp(VisibleRect::left().x, VisibleRect::bottom().y));
    lowerLayer->setAnchorPoint(ccp(0,0));
    lowerLayer->ignoreAnchorPointForPosition(false);
    layer->addChild(lowerLayer, 0);
    
    int mySize = lowerLayer->getContentSize().height / 3;
    
    // Button SAILKAPENA
    CCTexture2D *texture1 = CCTextureCache::sharedTextureCache()->addImage("botoia_normal.png");
    SpriteButton *pButton1 = SpriteButton::create(texture1 ,this, callfuncO_selector(MainMenuScene::menuSelector), 1.0f);
    pButton1->setTag(2);
    pButton1->setPosition(ccp(
                              lowerLayer->getContentSize().width / 2,
                              lowerLayer->getContentSize().height / 2));
    pButton1->setAnchorPoint(ccp(0.5f, 0.5f));
    CCLabelTTF *pLabel1 = CCLabelTTF::create("Sailkapena", "fonts/PT_Sans-Web-Bold.ttf", 30.0);
    pLabel1->setPosition(ccp(
                             lowerLayer->getContentSize().width / 2,
                             lowerLayer->getContentSize().height / 2));
    lowerLayer->addChild(pButton1);
    lowerLayer->addChild(pLabel1);
    
    // Button JOKATU
    CCTexture2D *texture2 = CCTextureCache::sharedTextureCache()->addImage("botoia_normal.png");
    SpriteButton *pButton2 = SpriteButton::create(texture2 ,this, callfuncO_selector(MainMenuScene::menuSelector), 1.0f);
    pButton2->setTag(1);
    pButton2->setPosition(ccp(
                              lowerLayer->getContentSize().width / 2,
                              (mySize * 3) - texture2->getContentSize().height));
    pButton2->setAnchorPoint(ccp(0.5f, 0.5f));
    CCLabelTTF *pLabel2 = CCLabelTTF::create("Jokatu", "fonts/PT_Sans-Web-Bold.ttf", 30.0);
    pLabel2->setPosition(ccp(
                             lowerLayer->getContentSize().width / 2,
                             (mySize * 3) - texture2->getContentSize().height));
    lowerLayer->addChild(pButton2);
    lowerLayer->addChild(pLabel2);
    
    // Button HONI BURUZ
    CCTexture2D *texture3 = CCTextureCache::sharedTextureCache()->addImage("botoia_normal.png");
    SpriteButton *pButton3 = SpriteButton::create(texture3 ,this, callfuncO_selector(MainMenuScene::menuSelector), 1.0f);
    pButton3->setTag(3);
    pButton3->setPosition(ccp(
                              lowerLayer->getContentSize().width / 2,
                              mySize - (texture2->getContentSize().height / 2)));
    pButton3->setAnchorPoint(ccp(0.5f, 0.5f));
    CCLabelTTF *pLabel3 = CCLabelTTF::create("Honi buruz", "fonts/PT_Sans-Web-Bold.ttf", 30.0);
    pLabel3->setPosition(ccp(
                             lowerLayer->getContentSize().width / 2,
                             mySize - (texture2->getContentSize().height / 2)));
    lowerLayer->addChild(pButton3);
    lowerLayer->addChild(pLabel3);
    
	return true;
}
Example #7
0
void SceneManager::goStop()
{
	CCLayerColor* layer = StopLayer::create();
	layer->initWithColor(ccc4(0, 0, 0, 125));
	SceneManager::push(layer);
}