本文整理汇总了C++中CCMenuItemImage::setNormalSpriteFrame方法的典型用法代码示例。如果您正苦于以下问题:C++ CCMenuItemImage::setNormalSpriteFrame方法的具体用法?C++ CCMenuItemImage::setNormalSpriteFrame怎么用?C++ CCMenuItemImage::setNormalSpriteFrame使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCMenuItemImage
的用法示例。
在下文中一共展示了CCMenuItemImage::setNormalSpriteFrame方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void LevelGame05::musicCallback(CCObject *pSender)
{
CCMenu *pmenu=(CCMenu *)getChildByTag(101);
pmenu->setEnabled(true);
CCSpriteFrameCache *cache = CCSpriteFrameCache::sharedSpriteFrameCache();
CCLayerColor *layer=( CCLayerColor *)getChildByTag(80);
if(isMusic == true)
{
isMusic = false;
/*CCDirector::sharedDirector()->end();*/
CCMenu* pMenu = (CCMenu *)layer->getChildByTag(128);
CCMenuItemImage *Item = (CCMenuItemImage *)pMenu->getChildByTag(127);
Item->setNormalSpriteFrame(cache->spriteFrameByName("close-pause-music.png"));
if(flagMusic == true)
SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic();
}
else
{
isMusic =true;
CCMenu* pMenu = (CCMenu *)layer->getChildByTag(128);
CCMenuItemImage *Item = (CCMenuItemImage *)pMenu->getChildByTag(127);
Item->setNormalSpriteFrame(cache->spriteFrameByName("pause-music.png"));
if(flagMusic == true)
{
SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic();
}
else
{
SimpleAudioEngine::sharedEngine()->playBackgroundMusic("back2.mp3",true);
flagMusic = true;
}
}
//removeChildByTag(80);
}
示例2: onHandlePropTypeSpriteFrame
NS_CC_EXT_BEGIN
void CCMenuItemImageLoader::onHandlePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCSpriteFrame * pCCSpriteFrame, CCBReader * pCCBReader) {
if(strcmp(pPropertyName, PROPERTY_NORMALDISPLAYFRAME) == 0) {
if(pCCSpriteFrame != NULL) {
((CCMenuItemImage *)pNode)->setNormalSpriteFrame(pCCSpriteFrame);
// #HLP_BEGIN
// #resource_scale_fix
CCMenuItemImage *item = (CCMenuItemImage *)pNode;
item->setNormalSpriteFrame(pCCSpriteFrame);
if(item->getTag() != TAG_INTERNET_MENU_ITEM_IMAGE){
item->setScale(item->getScale() * CC_CONTENT_SCALE_FACTOR() / CC_RESOURCE_SCALE_FACTOR());
}
// #HLP_END
}
} else if(strcmp(pPropertyName, PROPERTY_SELECTEDDISPLAYFRAME) == 0) {
if(pCCSpriteFrame != NULL) {
((CCMenuItemImage *)pNode)->setSelectedSpriteFrame(pCCSpriteFrame);
}
} else if(strcmp(pPropertyName, PROPERTY_DISABLEDDISPLAYFRAME) == 0) {
if(pCCSpriteFrame != NULL) {
((CCMenuItemImage *)pNode)->setDisabledSpriteFrame(pCCSpriteFrame);
}
} else {
CCMenuItemLoader::onHandlePropTypeSpriteFrame(pNode, pParent, pPropertyName, pCCSpriteFrame, pCCBReader);
}
}
示例3: receivePersonalData
void LayerLogin::receivePersonalData(){
Message* revMsg1 = (Message *)CData::getCData()->m_dictionary->objectForKey(103);
CData::getCData()->m_dictionary->removeObjectForKey(103);
if(revMsg1){
this->unschedule(schedule_selector(LayerLogin::receivePersonalData));
// editBoxUsername->removeFromParent();
// editBoxPassword->removeFromParent();
denglu1=revMsg1->data;
CData::getCData()->setSendVal(denglu1);
printf("------%s\n",denglu1);
pSpriteDialogLogin->removeFromParent();
load->removeFromParent();
// CCSprite *pSpriteselector = CCSprite::createWithSpriteFrameName("button_bg.png");// CCSprite::create("button_bg.png");
// CCMenuItemSprite *pMenuItemSelector = CCMenuItemSprite::create(pSpriteselector, pSpriteselector, this,SEL_MenuHandler(&LayerLogin::menuItemCallbackStart));
// pMenuItemSelector->setPosition(0, 130);
// CCMenuItemImage *pMenuItemStart = CCMenuItemImage::create("start_up.png", "start_down.png", this,SEL_MenuHandler(&LayerLogin::menuItemCallbackStart));
CCMenuItemImage *pMenuItemStart = CCMenuItemImage::create();
pMenuItemStart->setNormalSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("login_start_1.png"));
pMenuItemStart->setSelectedSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("login_start_2.png"));
pMenuItemStart->setTarget(this, SEL_MenuHandler(&LayerLogin::menuItemCallbackStart));
CCMenu *pMenu = CCMenu::create(pMenuItemStart,NULL);
this->addChild(pMenu,2);
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
pMenu->setPosition(winSize.width/2, 180);
}
}
示例4: onLoadScene
//-------------------------------------------------------------------------
// 其他逻辑初始化
void CShopTestScene::onLoadScene()
{
setAutoRemoveUnusedTexture( true );
// 根窗口,用来挂载显示物件
{
m_pRootWindow = FKCW_UIWidget_WidgetWindow::create();
m_pRootWindow->setMultiTouchEnabled(true);
this->addChild(m_pRootWindow);
}
// 返回按钮
{
CCMenu *pMenu = CCMenu::create();
pMenu->setPosition(CCPointZero);
addChild(pMenu);
CCMenuItemImage* pBtn = CCMenuItemImage::create();
CCSpriteFrame* pFrame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("back_button_normal_e.png");
pBtn->setNormalSpriteFrame(pFrame);
pFrame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("back_button_touch_e.png");
pBtn->setSelectedSpriteFrame(pFrame);
pBtn->setTarget(this, menu_selector(CShopTestScene::onClick));
pBtn->setPosition(SCREEN_CENTER_POS + ccp(0,400));
pMenu->addChild(pBtn);
}
}
示例5: initClickMenu
void BalloonItemClick::initClickMenu(CCSprite* pSpriteIcon)
{
// 加载按钮图形
CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("texture/items/items.plist");
// 创建按钮
CCMenuItemImage* pMenuItemImage = CCMenuItemImage::create();
// 设置按钮的图片
// pMenuItemImage->setNormalImage(CCSprite::create("texture/items/item_btn_normal.png"));
pMenuItemImage->setNormalSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("item_btn_normal.png"));
// pMenuItemImage->setSelectedSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("item_btn_normal.png"));
// 顺便这里更新下控件的大小
setContentSize(pMenuItemImage->getContentSize());
// 设置按下后的回调函数
pMenuItemImage->setTarget(this, menu_selector(BalloonItemClick::onPressMenuClick));
// 设置按钮
m_pMenuClick = CCMenu::create();
m_pMenuClick->addChild(pMenuItemImage);
CC_SAFE_RETAIN(m_pMenuClick);
// 设置按钮居中对齐
m_pMenuClick->setPosition(ccpMult(ccpFromSize(getContentSize()), 0.5f));
// 设置按下后的图片放大效果
ControlUtil::sharedControlUtil()->SetMenuItemSelectedImageWithNormalImage(m_pMenuClick, 1.2f);
// 添加到界面上
addChild(m_pMenuClick);
m_pSpriteIcon = pSpriteIcon;
m_pSpriteIcon->setPosition(ccpMult(ccpFromSize(getContentSize()), 0.5f));
CC_SAFE_RETAIN(m_pSpriteIcon);
addChild(m_pSpriteIcon);
}
示例6: init
bool GameSprite_Rice::init()
{
if (!CCSprite::init()) {
return false;
}
this->setContentSize(CCSize(500, 70));
addRiceTime = RICEADDTIME;
riceNum = 0;
nowTime = 0;
nowTime = this->getCurrentTime();
//字体背景.
CCMenuItemImage *labelBgSprite = CCMenuItemImage::create();
labelBgSprite->setNormalSpriteFrame(GameShare_Texture::sharedTexture()->GetSpriteFrameByCCRect(akoomenu_image, CCRect(1763, 255, 120, 49)));
labelBgSprite->setAnchorPoint(CCPointZero);
labelBgSprite->setPosition(CCPointZero);
labelBgSprite->setTag(Key_Add);
CCMenu* pMenu = CCMenu::create(labelBgSprite, NULL);
pMenu->setPosition(ccp(300,0));
pMenu->setTag(Key_Add);
this->addChild(pMenu);
//时间标签.
CCLabelTTF *timeLabel = CCLabelTTF::create("", "Arial", 20);
ccColor3B color = ccc3(95, 46, 33);
char strTime[32];
sprintf(strTime,"%d:%d%d",addRiceTime/60,addRiceTime%60/10,addRiceTime%60%10);
timeLabel->setColor(color);
timeLabel->setString(strTime);
timeLabel->setTag(Key_Time);
timeLabel->setPosition(ccp(pMenu->getPositionX()+40, pMenu->getPositionY()+20));
this->addChild(timeLabel);
//饭的背景
CCSprite *riceBgSprite = GameShare_Texture::sharedTexture()->GetSpriteByCCRect(akoomenu_image, CCRect(1, 1570, 278, 30));
riceBgSprite->setAnchorPoint(CCPointZero);
riceBgSprite->setPosition(ccp(0,5));
this->addChild(riceBgSprite);
this->schedule(schedule_selector(GameSprite_Rice::timeUpdate), 1.0);
return true;
}
示例7: buildAndPlaceTile
CCMenuItemImage* BaseScene::buildAndPlaceTile(const char *normalFrameName, const char *selectedFrameName, int tilePosX, int tilePosY)
{
CCMenuItemImage* menuButton = CCMenuItemImage::create();
menuButton->setNormalSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(normalFrameName));
menuButton->setSelectedSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(selectedFrameName));
menuButton->setDisabledSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(selectedFrameName));
//menuButton->setTarget(this, menu_selector(HomeScene::getZOrder));
menuButton->setAnchorPoint(ccp(0.0, 1.0));
_tileMenu->addChild(menuButton);
float onePosX = AppDelegate::SCREEN_WIDTH * 0.348;
float onePosY = AppDelegate::SCREEN_HEIGHT * 0.764;
float tileHeight = menuButton->getContentSize().height;
float gap = 7 * AppDelegate::SCREEN_SCALE_FACTOR;
float desiredPosX = onePosX + ((gap + tileHeight) * tilePosX);
float desiredPosY = onePosY - ((gap + tileHeight) * tilePosY);
menuButton->setPosition(desiredPosX, desiredPosY);
return menuButton;
}
示例8: init
// on "init" you need to initialize your instance
bool CGameMenu::init()
{
bool bRet = false;
do
{
CC_BREAK_IF(! CCLayer::init());
CCSize size = CCDirector::sharedDirector()->getWinSize();
// 菜单列表
CCSpriteFrameCache *pCache = CCSpriteFrameCache::sharedSpriteFrameCache();
pCache->addSpriteFramesWithFile("Image/GameMenu.plist");
// 菜单背景
CCSprite* m_pBackground = CCSprite::createWithSpriteFrame(pCache->spriteFrameByName("Background.png"));
m_pBackground->setPosition(ccp(size.width/2, size.height/2));
this->addChild(m_pBackground, 0);
// 星星
CCSprite* pStar = CCSprite::create("Image/Star.png");
CC_BREAK_IF(! pStar);
pStar->setPosition(ccp(size.width/2, size.height/2));
this->addChild(pStar, 1);
CCActionInterval* actionFade = CCFadeOut::create(2.0f);
CCActionInterval* actionFadeBack = actionFade->reverse();
CCActionInterval* seq2 = (CCActionInterval*)CCSequence::create(actionFade, actionFadeBack, NULL);
CCRepeatForever* pRepeatForever = CCRepeatForever::create(seq2);
pStar->runAction(pRepeatForever);
// 标题
CCSprite* pTitle = CCSprite::create("Image/Title.png");
CC_BREAK_IF(! pTitle);
pTitle->setPosition(ccp(size.width/2, size.height - 70));
this->addChild(pTitle, 2);
// 开始游戏
CCMenuItemImage *pMenuStart = CCMenuItemImage::create();
//pMenuStart->initWithTarget(this, menu_selector(CGameMenu::menuStartCallback));
pMenuStart->setCallback( CC_CALLBACK_1(CGameMenu::menuStartCallback,this) );
pMenuStart->setNormalSpriteFrame(pCache->spriteFrameByName("StartNormal.png"));
pMenuStart->setSelectedSpriteFrame(pCache->spriteFrameByName("StartSelected.png"));
pMenuStart->setPosition(ccp(size.width/2, 110));
// 游戏配置
CCMenuItemImage *pMenuOption = CCMenuItemImage::create();
//pMenuOption->initWithTarget(this, menu_selector(CGameMenu::menuOptionCallback));
pMenuOption->setCallback( CC_CALLBACK_1(CGameMenu::menuOptionCallback,this) );
pMenuOption->setNormalSpriteFrame(pCache->spriteFrameByName("OptionNormal.png"));
pMenuOption->setSelectedSpriteFrame(pCache->spriteFrameByName("OptionSelected.png"));
pMenuOption->setPosition(ccp(size.width/2, 75));
// 游戏结束
CCMenuItemImage *pMenuExit = CCMenuItemImage::create();
//pMenuExit->initWithTarget(this, menu_selector(CGameMenu::menuExitCallback));
pMenuExit->setCallback( CC_CALLBACK_1(CGameMenu::menuExitCallback,this) );
pMenuExit->setNormalSpriteFrame(pCache->spriteFrameByName("ExitNormal.png"));
pMenuExit->setSelectedSpriteFrame(pCache->spriteFrameByName("ExitSelected.png"));
pMenuExit->setPosition(ccp(size.width/2, 40));
// 游戏菜单
CCMenu *pMenu = CCMenu::create(pMenuStart,pMenuOption, pMenuExit, NULL);
pMenu->setPosition(ccp(0, 0));
this->addChild(pMenu, 3);
// 陨石掉落特效
m_pMeteorolite = CCParticleSun::create();
m_pMeteorolite->setTexture(CCTextureCache::sharedTextureCache()->addImage("Image/Fire.png"));
this->addChild(m_pMeteorolite, 1);
move(0);
this->schedule(schedule_selector(CGameMenu::move), 5.0f);
// 飞机
CCSprite* pPlane = CCSprite::create("Image/PlaneIco.png");
CC_BREAK_IF(! pPlane);
pPlane->setPosition(ccp(size.width/2, size.height/2));
this->addChild(pPlane, 2);
bRet = true;
}
while(0);
return bRet;
}
示例9:
bool LevelGame04::init()
{
if ( !CCLayer::init() )
{
return false;
}
isFailed = false;
flagMusic = false;
isMenu=0;
//cocos2d-x3.0中的点击事件
//auto dispatcher = Director::getInstance()->getEventDispatcher();
//auto touchListener = EventListenerTouchOneByOne::create();
//touchListener->onTouchBegan = CC_CALLBACK_2(HistoryGame02::onTouchBegan, this);
//dispatcher->addEventListenerWithSceneGraphPriority(touchListener, this);
CCUserDefault::sharedUserDefault()->setIntegerForKey("level_4", 1);
CCUserDefault::sharedUserDefault()->flush();
//加入背景
CCSize size = CCDirector::sharedDirector()->getWinSize();
CCSpriteFrameCache *cache = CCSpriteFrameCache::sharedSpriteFrameCache();
cache->addSpriteFramesWithFile("level-4.plist");
CCSprite* sprite =CCSprite::createWithSpriteFrameName("background-4.png");
CCSize sprite_size = sprite->getContentSize();
sprite->setScaleX(size.width/sprite_size.width);
sprite->setScaleY(size.height/sprite_size.height);
sprite->setPosition(CCPoint(size.width*0.5,size.height*0.5));
sprite->setTag(98);
this->addChild(sprite);
//ClickME图标
CCMenuItemImage *clickmeItem = CCMenuItemImage::create();
clickmeItem->setNormalSpriteFrame(cache->spriteFrameByName("clickme_1.png"));
clickmeItem->setSelectedSpriteFrame(cache->spriteFrameByName("clickme_2.png"));
clickmeItem->initWithTarget(this,menu_selector(LevelGame04::clickmeCallback));
clickmeItem->setPosition(ccp(size.width / 2 , size.height / 2));
CCMenu* pmenu= CCMenu::create(clickmeItem, NULL);
pmenu->setPosition(CCPointZero);
pmenu->setTag(100);
//pmenu->setEnabled(false);
this->addChild(pmenu);
//ME和NU两个图标
CCMenuItemImage *meItem = CCMenuItemImage::create();
meItem->setNormalSpriteFrame(cache->spriteFrameByName("ME.png"));
meItem->setSelectedSpriteFrame(cache->spriteFrameByName("ME.png"));
meItem->initWithTarget(this,menu_selector(LevelGame04::meCallback));
meItem->setPosition(ccp(100, size.height*0.9));
meItem->setTag(101);
CCMenu* meMenu= CCMenu::create(meItem, NULL);
meMenu->setPosition(CCPointZero);
meMenu->setTag(103);
this->addChild(meMenu,1);
CCMenuItemImage *nuItem = CCMenuItemImage::create();
nuItem->setNormalSpriteFrame(cache->spriteFrameByName("NU.png"));
nuItem->setSelectedSpriteFrame(cache->spriteFrameByName("NU.png"));
//yiItem->initWithTarget(this,menu_selector(LevelGame01::yiCallback));
nuItem->setPosition(ccp(184, size.height*0.9));
CCMenu* nuMenu= CCMenu::create(nuItem, NULL);
nuMenu->setPosition(CCPointZero);
nuMenu->setTag(102);
this->addChild(nuMenu,1);
// cache->addSpriteFramesWithFile("UIResoure.plist");
//batch = CCSpriteBatchNode::create("UIResoure.png");
//this->addChild(batch);
CCMenuItemImage *pauseItem = CCMenuItemImage::create();
pauseItem->setNormalSpriteFrame(cache->spriteFrameByName("pause-1.png"));
pauseItem->setSelectedSpriteFrame(cache->spriteFrameByName("pause-2.png"));
pauseItem->initWithTarget(this, menu_selector(LevelGame04::pauseCallback));
pauseItem->setPosition(CCPoint(size.width-100,size.height*0.9));
CCMenu *pauseMenu = CCMenu::create(pauseItem, NULL);
pauseMenu->setPosition(CCPointZero);
pauseMenu->setTag(104);
this->addChild(pauseMenu, 1);
if(isMusic == true)
{
SimpleAudioEngine::sharedEngine()->playBackgroundMusic("back2.mp3",true);
flagMusic = true;
}
return true;
}
示例10: buildHeader
void BaseScene::buildHeader(int highlightIndex, const char* title, const char* description)
{
_currentMenuIndex = highlightIndex;
CCMenuItemImage* homeButton = CCMenuItemImage::create();
homeButton->setNormalSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_home_nrl"));
homeButton->setSelectedSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_home_prd"));
homeButton->setDisabledSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_home_prd"));
homeButton->setTarget(this, menu_selector(BaseScene::loadHomeScene));
homeButton->setAnchorPoint(ccp(1.0f, 1.0f));
CCMenuItemImage* fbActionButton = CCMenuItemImage::create();
fbActionButton->setNormalSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_fb_action_nrl"));
fbActionButton->setSelectedSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_fb_action_prd"));
fbActionButton->setDisabledSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_fb_action_dis"));
fbActionButton->setTarget(this, menu_selector(BaseScene::loadFBActionScene));
fbActionButton->setAnchorPoint(ccp(1.0f, 1.0f));
if (EziSocialObject::sharedObject()->isFacebookSessionActive() == false)
{
fbActionButton->setEnabled(false);
}
CCMenuItemImage* helpButton = CCMenuItemImage::create();
helpButton->setNormalSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_help_nrl"));
helpButton->setSelectedSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_help_prd"));
helpButton->setDisabledSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_help_prd"));
helpButton->setTarget(this, menu_selector(BaseScene::loadHelpScene));
helpButton->setAnchorPoint(ccp(1.0f, 1.0f));
switch (highlightIndex)
{
case 0:
homeButton->setEnabled(false);
break;
case 1:
fbActionButton->setEnabled(false);
break;
case 2:
helpButton->setEnabled(false);
break;
default:
break;
}
CCMenu* homeMenu = CCMenu::create(homeButton, fbActionButton, helpButton, NULL);
homeMenu->alignItemsHorizontally();
this->addChild(homeMenu);
PlaceNode(homeMenu, 0.88, 0.98);
// Add a line.
CCLayerColor* lineLayer = CCLayerColor::create(ccc4(204, 204, 204, 204),
CCDirector::sharedDirector()->getVisibleSize().width,
1.0 * AppDelegate::SCREEN_SCALE_FACTOR);
this->addChild(lineLayer);
PlaceNode(lineLayer, 0.0, 0.8);
lineLayer->setPositionY(homeMenu->getPositionY() - homeButton->getContentSize().height - (7 * AppDelegate::SCREEN_SCALE_FACTOR));
// Add Title
CCLabelTTF* titleLabel = CCLabelTTF::create(title, "Arial", 50.0 * AppDelegate::SCREEN_SCALE_FACTOR);
this->addChild(titleLabel);
titleLabel->setAnchorPoint(ccp(0.0f, 0.0f));
//PlaceNode(titleLabel, 0.02, 0.98);
CCLabelTTF* descriptionLabel = CCLabelTTF::create(description,
"Arial", SCALED_VALUE(22.0f));
this->addChild(descriptionLabel);
descriptionLabel->setAnchorPoint(ccp(0.0f, 0.0f));
PlaceNode(descriptionLabel, 0.02, 0.98);
descriptionLabel->setPositionY(homeMenu->getPositionY() - homeButton->getContentSize().height);
descriptionLabel->setColor(ccc3(204, 204, 204));
titleLabel->cocos2d::CCNode::setPosition(descriptionLabel->getPositionX(),
descriptionLabel->getPositionY() + descriptionLabel->getContentSize().height - 2.0f);
}