本文整理汇总了C++中CCTableView::setContentOffset方法的典型用法代码示例。如果您正苦于以下问题:C++ CCTableView::setContentOffset方法的具体用法?C++ CCTableView::setContentOffset怎么用?C++ CCTableView::setContentOffset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCTableView
的用法示例。
在下文中一共展示了CCTableView::setContentOffset方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
KDbool TestList::init ( KDvoid )
{
if ( !CCLayer::initWithVisibleViewport ( ) )
{
return KD_FALSE;
}
const CCSize& tLyrSize = this->getContentSize ( );
CCLayerGradient* pBG = CCLayerGradient::create ( ccc4 ( 52, 84, 236, 200 ), ccc4 ( 149, 0, 202, 200 ) );
pBG->setContentSize ( tLyrSize );
this->addChild ( pBG, -10 );
CCSprite* pBottomLeft = CCSprite::create ( "ccb/jungle-left.png" );
this->addChild ( pBottomLeft, 10 );
pBottomLeft->setScale ( 1.5f );
pBottomLeft->setOpacity ( 210 );
pBottomLeft->setPositionWithParent ( kCCAlignmentBottomLeft );
CCSprite* pBottomRight = CCSprite::create ( "ccb/jungle-right.png" );
this->addChild ( pBottomRight, 10 );
pBottomRight->setScale ( 1.5f );
pBottomRight->setOpacity ( 210 );
pBottomRight->setPositionWithParent ( kCCAlignmentBottomRight );
CCMenuItemImage* pQuit = CCMenuItemImage::create
(
"xm_supports/CloseNormal.png", "xm_supports/CloseSelected.png", this, menu_selector ( TestList::onQuit )
);
pQuit->setScale ( 1.2f );
pQuit->setPosition ( this, kCCAlignmentTopRight, ccp ( 10, 10 ) );
this->addChild ( CCMenu::createWithItem ( pQuit ), 10 );
CCTableView* pTableView = CCTableView::create ( this, ccs ( tLyrSize.cx, tLyrSize.cy - 20.f ) );
this->addChild ( pTableView );
pTableView->setDelegate ( this );
pTableView->setDataSource ( this );
pTableView->setPosition ( ccp ( 0, 10 ) );
if ( s_tPrevPosition.x != -1 )
{
pTableView->setContentOffset ( s_tPrevPosition );
}
CCMenuItemFont::setFontSize ( 30 );
CCMenuItemFont::setFontName ( "fonts/ThonburiBold.ttf" );
return KD_TRUE;
}
示例2: initRoomTable
bool CCLobbyView::initRoomTable()
{
const CCPoint center = this->getCenter();
CCLOG("CCLobbyView::initRoomTable:1");
this->removeRoomTable();
this->_lobbyViewDataSource = new CCLobbyViewDataSource(this);
CCLOG("CCLobbyView::initRoomTable:2");
if (this->_lobbyViewDataSource) {
// this->_lobbyViewDataSource->autorelease();
// CC_SAFE_RETAIN(this->_lobbyViewDataSource);
CCSize tableSize = this->_lobbyViewDataSource->cellSizeForTable( NULL );
tableSize.height *= 10.0f;
CCLOG("CCLobbyView::initRoomTable:3 tableSize.height[%f]", tableSize.height);
CCTableView* table = CCTableView::create( this->_lobbyViewDataSource, tableSize );
CCLOG("CCLobbyView::initRoomTable:4");
if( table )
{
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
float posy = this->getEditName()->getContentSize().height;
posy += this->getConsole()->getContentSize().height;
table->setContentOffset( CCPointZero );
table->setDirection(kCCScrollViewDirectionVertical);
table->setPosition( ccp( center.x - ( tableSize.width * 0.5f ), winSize.height - posy - tableSize.height - FONT_SIZE(24) ) );
table->setDelegate( this );
table->setVerticalFillOrder(kCCTableViewFillTopDown);
table->setTouchEnabled( true );
this->addChild( table, 0, Child::CCTableView_roomTable );
table->reloadData();
this->setMinRoomsInView( 10 );
return true;
} else {
CCLOG("CCLobbyView::initRoomTable:5 table create failed");
}
}
return false;
}
示例3: init
bool CCLobbyView::init( CCNetworkLogic* network, const CCSize& mySize )
{
if( CCLayer::init() )
{
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
const CCPoint& center = ccpMult( ccpFromSize( mySize ), 0.5f );
CCPoint position = CCPointZero;
CCSize size = CCSizeZero;
int length = 0;
int fontSize = 0;
this->setNetwork( network );
CCSprite* s = CCSprite::create("Images/r1.png");
s->retain();
CCRect rect = CCRectZero;
rect.size = s->getContentSize();
s->release();
fontSize = 12;
CCLabelTTF* label = CCLabelTTF::create( "Connect", "fonts/American Typewriter.ttf", fontSize );
label->setColor( ccc3( 0, 0, 0 ) );
CCScale9Sprite* sprite = CCScale9Sprite::create("Images/r1.png", rect, rect );
sprite->setScaleX( 1.4f );
sprite->setScaleY( 0.8f );
CCControlButton* button = CCControlButton::create( label, sprite );
button->addTargetWithActionForControlEvents( this, cccontrol_selector( CCLobbyView::connectButtonCallback ), CCControlEventTouchUpInside);
button->setPreferredSize( rect.size );
position = center;
position.y -= 136;
position.x -= 100;
button->setPosition( position );
this->setConnectButton( button );
label = CCLabelTTF::create( "Create Room", "fonts/American Typewriter.ttf", fontSize );
label->setColor( ccc3( 0, 0, 0 ) );
sprite = CCScale9Sprite::create("Images/r1.png", rect, rect );
sprite->setScaleX( 1.4f );
sprite->setScaleY( 0.8f );
button = CCControlButton::create( label, sprite );
button->addTargetWithActionForControlEvents( this, cccontrol_selector( CCLobbyView::createGameButtonCallback ), CCControlEventTouchUpInside);
button->setPreferredSize( rect.size );
position = center;
position.y -= 136;
//position.x += 0;
button->setPosition( position );
this->setCreateGameButton( button );
label = CCLabelTTF::create( "Random Room", "fonts/American Typewriter.ttf", fontSize );
label->setColor( ccc3( 0, 0, 0 ) );
sprite = CCScale9Sprite::create("Images/r1.png", rect, rect );
sprite->setScaleX( 1.6f );
sprite->setScaleY( 0.8f );
button = CCControlButton::create( label, sprite );
button->addTargetWithActionForControlEvents( this, cccontrol_selector( CCLobbyView::joinGameButtonCallback ), CCControlEventTouchUpInside);
button->setPreferredSize( rect.size );
position = center;
position.y -= 136;
position.x += 100;
button->setPosition( position );
this->setRandomGameButton( button );
this->_lobbyViewDataSource = new CCLobbyViewDataSource( this );
fontSize = 16;
length = mySize.width;
size = this->_lobbyViewDataSource->cellSizeForTable( NULL );
size.height *= 3;
CCTableView* table = CCTableView::create( this->_lobbyViewDataSource, size );
table->setContentOffset( CCPointZero );
table->setDirection(kCCScrollViewDirectionVertical);
position = center;
position.x -= size.width * 0.5f;
position.y -= fontSize + ( size.height * 0.17f );
table->setPosition( position );
table->setDelegate( this );
table->setVerticalFillOrder(kCCTableViewFillTopDown);
this->setRoomTable( table );
table->reloadData();
fontSize = 16;
label = CCLabelTTF::create("Running games:", "fonts/American Typewriter.ttf", fontSize,
winSize, kCCTextAlignmentCenter, kCCVerticalTextAlignmentCenter);
position = center;
position.x -= size.width * 0.4f;
position.y += size.height - ( fontSize * 0.5f );
label->setPosition( position );
//label->setAnchorPoint( CCPointZero );
this->setRoomTableLabel( label );
fontSize = 16;
CCLabelTTF* console = CCLabelTTF::create("disconnected", "fonts/American Typewriter.ttf", fontSize,
winSize, kCCTextAlignmentCenter, kCCVerticalTextAlignmentCenter);
console->setColor( ccc3(255, 255, 255) );
console->setContentSize(winSize);
position = center;
position.y += 100;
console->setPosition( position );
//.........这里部分代码省略.........