Ejemplo n.º 1
0
CCScrollLayer* CCScrollLayer::layerWithLayers(CCArray * layers, float layerWidth, int space)
{	
	CCScrollLayer * pRet = new CCScrollLayer();
	if (pRet && pRet->initWithLayers(layers, layerWidth, space))
	{
		pRet->autorelease();
		return pRet;
	}
	CC_SAFE_DELETE(pRet);
	return NULL;
}
Ejemplo n.º 2
0
CCScrollLayer* CCScrollLayer::layerWithLayers(CCArray *layers, int widthOffset)
{	
	CCScrollLayer *pRet = new CCScrollLayer();
	if (pRet && pRet->initWithLayers(layers, widthOffset))
	{
		pRet->autorelease();
		return pRet;
	}
	CC_SAFE_DELETE(pRet);
	return NULL;
}
CCScrollLayer* CCScrollLayer::create ( CCArray* pLayers, KDfloat fWidth, KDint nWidthOffset )
{
	CCScrollLayer*	pRet = new CCScrollLayer ( );

	if ( pRet && pRet->initWithLayers ( pLayers, fWidth, nWidthOffset ) )
	{
		pRet->autorelease ( );
	}
	else
	{
		CC_SAFE_DELETE ( pRet );
	}

	return pRet;
}
Ejemplo n.º 4
0
void LevelScene::createLevelsLayer()
{
    CCArray *pLayers = CCArray::create();

    CCArray *pLevels = m_pKategoria->getPantailak();
    
    int numLevels = pLevels->count();
    
    int numberPages = numLevels / 4;
    
    if (numLevels % 4 > 0) {
        numberPages++;
    }
    
    int cont = 0;
    
    for (int i = 1; i <= numberPages; i++) {
        
        CCLayer *pContainer = CCLayer::create();
        CCLayer *pContentLayer = CCLayer::create();
        
        CCSize contentSize = CCSizeMake(500, 490);
        CCPoint contentPos = ccp(VisibleRect::center().x - contentSize.width/2, VisibleRect::center().y - contentSize.height/2);
        pContentLayer->setContentSize(contentSize);
        pContentLayer->setPosition(contentPos);
        
        CCPoint texturePosition[] = {ccp(122, 369), ccp(372, 369), ccp(122, 149), ccp(372, 149)};
        CCPoint labelPosition[] = {ccp(125, 250), ccp(375, 250), ccp(125, 30), ccp(375, 30)};
        
        int numberRows = numLevels - (4 * (i-1));
        
        if (numberRows > 4)
            numberRows = 4;
        
        for(int j = 1; j <= numberRows; j++) {
           
            LevelModel *pLevel = (LevelModel*) pLevels->objectAtIndex(cont);
            
            std::string imageName = CCFileUtils::sharedFileUtils()->getWriteablePath().append(pLevel->getList());
            
            CCTexture2D *pTexture = CCTextureCache::sharedTextureCache()->addImage("borde.png");
            SpriteButton *pLevelButton = SpriteButton::create(pTexture ,this, callfuncO_selector(LevelScene::levelClicked));
            pLevelButton->setPosition(texturePosition[j-1]);
            pLevelButton->setTag(cont);

            pTexture = CCTextureCache::sharedTextureCache()->addImage(imageName.c_str());
            CCSprite *pImageBorder = CCSprite::createWithTexture(pTexture);
            //pImageBorder->setAnchorPoint(ccp(0, 0));
            pImageBorder->setScale(imageScale);
            pImageBorder->setPosition(ccp(87, 95));
            pLevelButton->addChild(pImageBorder);
            
            pContentLayer->addChild(pLevelButton);
     
            
            CCLabelTTF *pLabel = CCLabelTTF::create(pLevel->getIzena(), fontList[0], 22.0);
            pLabel->setPosition(labelPosition[j-1]);
            pLabel->setColor(ccc3(63, 62, 62));
            pLabel->setDimensions(CCSizeMake(257, 50));
            pContentLayer->addChild(pLabel);
            
            cont++;
        }
        
        pContainer->addChild(pContentLayer);
        pLayers->addObject(pContainer);
    }
    
    CCScrollLayer *pScrollLayer = CCScrollLayer::nodeWithLayers(pLayers, 0);
    pScrollLayer->setPagesIndicatorPosition(ccp(VisibleRect::center().x, VisibleRect::bottom().y + 70));
    pScrollLayer->setDelegate(this);
    pScrollLayer->moveToPage(0);
    addChild(pScrollLayer);
}
Ejemplo n.º 5
0
//=============================================================
//=============================================================
CCScrollLayer* CCScrollLayer::scrollLayerWidthColor(const Color4B color,Size size)
{
    CCScrollLayer* scrollLayer = CCScrollLayer::create();
    scrollLayer->initWithColorWidthHeight(color, size.width, size.height);
    return  scrollLayer;
}