Exemplo n.º 1
0
void GamePlayScene::playCallback(cocos2d::Object *pSender)
{
    MenuItemImage *item = (MenuItemImage *)pSender ;
    
    
    item->setNormalSpriteFrame(SpriteFrame::create("btn-pause-n.png", playBtnRct)) ;
     item->setSelectedSpriteFrame(SpriteFrame::create("btn-pause-p.png", playBtnRct)) ;
}
Exemplo n.º 2
0
bool CGameLevel::init()
{
	LayerBack::init();

	g_iGameLevel = 1;
	size = winSize;


	// 选关列表
	SpriteFrameCache *pCache = SpriteFrameCache::sharedSpriteFrameCache();
	pCache->addSpriteFramesWithFile("Image/GameLevel.plist");

	// 选关背景
	SpriteFrame* pBG = pCache->spriteFrameByName("GameLevelBG.png");
	Sprite* pSprite = CCSprite::createWithSpriteFrame(pBG);
	pSprite->setPosition(ccp(size.width/2, size.height/2));
	pSprite->setScale(2.0f);
	pSprite->setRotation(90.0f);
	this->addChild(pSprite, 0);
	_pSprite = pSprite;
		
	/**背景特效	*/
	ParticleSystemQuad *emitter = ParticleSystemQuad::create("Image/Phoenix.plist");
	emitter->setPosition(ccp(size.width/2, size.height/2));
	this->addChild(emitter, 1);

	/**	关卡一按钮	*/
	MenuItemImage *pLevelOne = MenuItemImage::create();
	pLevelOne->setTarget(this, menu_selector(CGameLevel::setLevelMode));
	pLevelOne->setNormalSpriteFrame(pCache->spriteFrameByName("StartLevel1Normal.png")); 
	pLevelOne->setSelectedSpriteFrame(pCache->spriteFrameByName("StartLevel1Selected.png"));
	pLevelOne->setPosition(ccp(size.width*0.14f, size.height/2));
	pLevelOne->_ID = LEVEL_ONE;

	/**	关卡二按钮	*/
	MenuItemImage *pLevelTwo = MenuItemImage::create();
	pLevelTwo->setTarget(this, menu_selector(CGameLevel::setLevelMode));
	pLevelTwo->setNormalSpriteFrame(pCache->spriteFrameByName("StartLevel2Normal.png")); 
	pLevelTwo->setSelectedSpriteFrame(pCache->spriteFrameByName("StartLevel2Selected.png"));
	pLevelTwo->setPosition(ccp(size.width/2, size.height*0.8f));
	pLevelTwo->_ID = LEVEL_TWO;

	/**	关卡三按钮	*/
	MenuItemImage *pLevelThree = MenuItemImage::create();
	pLevelThree->setTarget(this, menu_selector(CGameLevel::setLevelMode));
	pLevelThree->setNormalSpriteFrame(pCache->spriteFrameByName("StartLevel3Normal.png")); 
	pLevelThree->setSelectedSpriteFrame(pCache->spriteFrameByName("StartLevel3Selected.png"));
	pLevelThree->setPosition(ccp(size.width*0.86f, size.height/2));
	pLevelThree->_ID = LEVEL_THREE;

	/**	游戏开始按钮	*/
	MenuItemImage *pStart = MenuItemImage::create();
	pStart->setTarget(this, menu_selector(CGameLevel::setLevelStart));
	pStart->setNormalSpriteFrame(pCache->spriteFrameByName("GameStartNormal.png")); 
	pStart->setSelectedSpriteFrame(pCache->spriteFrameByName("GameStartSelected.png"));
	pStart->setPosition(ccp(size.width/2, size.height*0.2f));

	/**	菜单	*/
	_menu->addChild(pLevelOne);
	_menu->addChild(pLevelTwo);
	_menu->addChild(pLevelThree);
	_menu->addChild(pStart);
	_menu->setPosition(ccp(0, 0));
	_menu->setZOrder(3);

	/**	选中特效	*/
	m_pSun = ParticleSun::create();
	pSprite->addChild(m_pSun, 1);
	m_pSun->setTexture(TextureCache::sharedTextureCache()->addImage("Image/Fire.png") );
	m_pSun->setPosition(_pSprite->convertToNodeSpace(ccp(size.width*0.14f, size.height / 2)));
	m_pSun->setStartSize(30);

	_menuItem->setTarget(this, menu_selector(CGameLevel::back));
	//_menuItem死活不出现

	return true;
}
void FriendListScene::buildScene()
{
    _friendDictionary.clear();
    _friendList.clear();
    _tableView = NULL;
    _downloadCount = 0;
    
    const char* headerString = "";
    
    switch (_selectedFriendCircle)
    {
        case ALL_FRIENDS:
            headerString = "All Friends";
            break;
        
        case INSTALLED_ONLY:
            headerString = "Friends Playing Game";
            break;
            
        case NON_PLAYING_ONLY:
            headerString = "Friends not Playing Game";
            break;
            
        case MY_DEVICE_ONLY:
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
            headerString = "Friends playing on iOS Device";
#else
            headerString = "Friends playing on Android Device";
#endif
        default:
            break;
    }
    
    //_friendList = CCArray::createWithCapacity(5);
    //_friendList->retain();
    CCLOG("ALL Request count = %lu", _friendList.size());
    
    // Add background layers to the scene.
    LayerColor *bg = LayerColor::create(Color4B(255, 255, 255, 255), AppDelegate::SCREEN_WIDTH, AppDelegate::SCREEN_HEIGHT);
    this->addChild(bg);
    
    LayerColor *secondBG = LayerColor::create(Color4B(95, 95, 95, 255),
                                                  AppDelegate::SCREEN_WIDTH - SCALED_VALUE(20.0f),
                                                  AppDelegate::SCREEN_HEIGHT - SCALED_VALUE(20.0f));
    
    secondBG->setPosition(Point(SCALED_VALUE(10.0f), SCALED_VALUE(10.0f)));
    this->addChild(secondBG);
    
    // Set the table header.
    LayerColor *header = LayerColor::create(Color4B(66, 66, 66, 255),
                                                AppDelegate::SCREEN_WIDTH - SCALED_VALUE(20.0f),
                                                SCALED_VALUE(100.0f));
    header->setAnchorPoint(Point(0, 0));
    header->setPosition(Point(SCALED_VALUE(10.0f), AppDelegate::SCREEN_HEIGHT - SCALED_VALUE(110.0f)));
    this->addChild(header);
    
    // Set the header text.
    auto headerText = LabelTTF::create(headerString, "Arial", SCALED_VALUE(40.0f));
    headerText->setAnchorPoint(Point(0.0f, 0.5f));
    header->addChild(headerText);
    headerText->setPositionX(SCALED_VALUE(28.0f));
    headerText->setPositionY(header->getContentSize().height/2);
    
    // Add back button go back to previous scene
    MenuItemImage *backButton = MenuItemImage::create();
    backButton->setNormalSpriteFrame(SpriteFrameCache::getInstance()->getSpriteFrameByName("btn_table_back_nrl"));
    backButton->setSelectedSpriteFrame(SpriteFrameCache::getInstance()->getSpriteFrameByName("btn_table_back_prd"));
    
    backButton->setCallback(CC_CALLBACK_1(FriendListScene::backButtonPressed, this));

    backButton->setAnchorPoint(Point(1.0f, 0.5));
    Menu* backMenu = Menu::create(backButton, NULL);
    header->addChild(backMenu);
    backMenu->setPositionX(header->getContentSize().width - SCALED_VALUE(20.0f));
    backMenu->setPositionY(header->getContentSize().height/2);
    
    
    // Create the table view.
    float tableHeight = bg->getContentSize().height - secondBG->getPositionY() - (header->getContentSize().height) - SCALED_VALUE(10);
    _tableView = TableView::create(this, Size(secondBG->getContentSize().width, tableHeight));
    _tableView->setAnchorPoint(Point(0, 0.0));
    _tableView->setDirection(ScrollView::Direction::VERTICAL);
    _tableView->setPosition(Point(SCALED_VALUE(10.0f), SCALED_VALUE(10)));
    _tableView->setDelegate(this);
    this->addChild(_tableView);
}