本文整理汇总了C++中MenuItemSprite::getPositionY方法的典型用法代码示例。如果您正苦于以下问题:C++ MenuItemSprite::getPositionY方法的具体用法?C++ MenuItemSprite::getPositionY怎么用?C++ MenuItemSprite::getPositionY使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MenuItemSprite
的用法示例。
在下文中一共展示了MenuItemSprite::getPositionY方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ShowGameOver
void UI::ShowGameOver( cocos2d::Layer *layer )
{
Size screenSize = Director::getInstance( )->getVisibleSize( );
Sprite *background = Sprite::create( GAME_OVER_BACKGROUND );
background->setPosition( SonarCocosHelper::UI::GetScreenCenter( ) );
background->setOpacity( 0 );
layer->addChild( background );
background->runAction( Sequence::create( DelayTime::create( PIECE_FADE_IN_TIME * 2.5 ), FadeIn::create( GAME_OVER_BACKGROUND_FADE_IN_TIME ), NULL ) );
MenuItemImage *overlayWindowItem = MenuItemImage::create( GAME_OVER_WINDOW, GAME_OVER_WINDOW, GAME_OVER_WINDOW, NULL );
MenuItemSprite *retryItem = MenuItemSprite::create( Sprite::create( RETRY_BUTTON ), Sprite::create( RETRY_BUTTON_PRESSED ), Sprite::create( RETRY_BUTTON ), CC_CALLBACK_1( UI::Retry, this ) );
retryItem->setPosition( Vec2( overlayWindowItem->getContentSize( ).width / 4, retryItem->getPositionY( ) ) );
MenuItemSprite *mainMenuItem = MenuItemSprite::create( Sprite::create( HOME_BUTTON ), Sprite::create( HOME_BUTTON_PRESSED ), Sprite::create( HOME_BUTTON_PRESSED ), CC_CALLBACK_1( UI::GoToMainMenu, this ) );
mainMenuItem->setPosition( Vec2( -overlayWindowItem->getContentSize( ).width / 4, mainMenuItem->getPositionY( ) ) );
Menu *menu = Menu::create( overlayWindowItem, retryItem, mainMenuItem, NULL );
menu->setPosition( Vec2( SonarCocosHelper::UI::GetScreenCenter( ).x, SonarCocosHelper::UI::GetScreenCenter( ).y + screenSize.height ) );
layer->addChild( menu );
EaseBounceOut *menuActionEasing = EaseBounceOut::create( MoveTo::create( MENU_MOVE_BOUNCE_DURATION, SonarCocosHelper::UI::GetScreenCenter( ) ) );
Sequence *menuShowSeq = Sequence::create( DelayTime::create( PIECE_FADE_IN_TIME * 2.5 ), menuActionEasing, NULL );
menu->runAction( menuShowSeq );
}
示例2:
UI::UI( cocos2d::Layer *layer, int &gameState )
{
this->gameState = &gameState;
Size screenSize = Director::getInstance( )->getVisibleSize( );
Vec2 origin = Director::getInstance( )->getVisibleOrigin( );
MenuItemSprite *pauseItem = MenuItemSprite::create( Sprite::create( PAUSE_BUTTON ), Sprite::create( PAUSE_BUTTON_PRESSED ), Sprite::create( PAUSE_BUTTON_PRESSED ), CC_CALLBACK_1( UI::PauseGame, this ) );
pauseItem->setPosition( Vec2( screenSize.width - ( pauseItem->getContentSize( ).width / 2 ) + origin.x, screenSize.height - ( pauseItem->getContentSize( ).height / 2 ) + origin.y ) );
Menu *menuButtons = Menu::create( pauseItem, NULL );
menuButtons->setPosition( Vec2::ZERO );
layer->addChild( menuButtons );
pausebackground = Sprite::create( PAUSE_BACKGROUND );
pausebackground->setPosition( SonarCocosHelper::UI::GetScreenCenter( ) );
pausebackground->setOpacity( 0 );
layer->addChild( pausebackground );
MenuItemImage *overlayPauseWindowItem = MenuItemImage::create( PAUSE_WINDOW, PAUSE_WINDOW, PAUSE_WINDOW, NULL );
MenuItemSprite *resumeItem = MenuItemSprite::create( Sprite::create( RESUME_BUTTON ), Sprite::create( RESUME_BUTTON_PRESSED ), Sprite::create( RESUME_BUTTON ), CC_CALLBACK_1( UI::PauseGame, this ) );
resumeItem->setPosition( Vec2( -overlayPauseWindowItem->getContentSize( ).width / 4, resumeItem->getPositionY( ) ) );
MenuItemSprite *mainMenuItem = MenuItemSprite::create( Sprite::create( HOME_BUTTON ), Sprite::create( HOME_BUTTON_PRESSED ), Sprite::create( HOME_BUTTON_PRESSED ), CC_CALLBACK_1( UI::GoToMainMenu, this ) );
mainMenuItem->setPosition( Vec2( overlayPauseWindowItem->getContentSize( ).width / 4, mainMenuItem->getPositionY( ) ) );
pauseMenu = Menu::create( overlayPauseWindowItem, resumeItem, mainMenuItem, NULL );
pauseMenu->setPosition( Vec2( SonarCocosHelper::UI::GetScreenCenter( ).x, SonarCocosHelper::UI::GetScreenCenter( ).y + screenSize.height ) );
layer->addChild( pauseMenu );
}