本文整理汇总了C++中CCMenuItemImage::setOpacity方法的典型用法代码示例。如果您正苦于以下问题:C++ CCMenuItemImage::setOpacity方法的具体用法?C++ CCMenuItemImage::setOpacity怎么用?C++ CCMenuItemImage::setOpacity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCMenuItemImage
的用法示例。
在下文中一共展示了CCMenuItemImage::setOpacity方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: startGame
void TetrisGameLayer::startGame(){
G_current_HandleType = new LongBlock_Type();
G_current_HandleType->init();
CCSize size = CCDirector::sharedDirector()->getWinSize();
//控制按钮//
CCMenuItemImage * left = CCMenuItemImage::create("left.png", "left.png");
left->setTarget(this, menu_selector(TetrisGameLayer::leftButtonPressed));
left->setScale(0.5);
CCMenuItemImage * right = CCMenuItemImage::create("right.png", "right.png");
right->setTarget(this, menu_selector(TetrisGameLayer::rightButtonPressed));
left->setAnchorPoint(ccp(0, 0));
right->setAnchorPoint(ccp(0, 0));
right->setScale(0.5);
right->setPosition(ccp(size.width/2+size.width/4, 0));
CCMenuItemImage * down = CCMenuItemImage::create("down.png", "down.png");
down->setTarget(this, menu_selector(TetrisGameLayer::downButtonPressed));
down->setAnchorPoint(ccp(0,0));
down->setScale(0.5);
down->setPosition(ccp(size.width/2 -100,0));
down->setOpacity(0.7*255);
CCMenu * menu = CCMenu::create(left,down,right, NULL);
menu->setAnchorPoint(ccp(0, 0));
menu->setPosition(ccp(0, 0));
this->addChild(menu);
}
示例2:
void ConsoleCocos2dxLayer::onConsoleButtonClick(CCObject* pSender)
{
CCMenuItemImage* consoleButton = static_cast<CCMenuItemImage*>(pSender);
if (consoleButton->getOpacity() > 128) // seems in console mode
{
consoleButton->setOpacity(128);
// remove console view
removeChild(m_consoleView);
}
else // seems not in console mode
{
consoleButton->setOpacity(255);
// add console view
addChild(m_consoleView);
}
}
示例3: setContent
void MainHeaderLayer::setContent(BaseSprite* header)
{
if (mHeader)
{
mHeader->removeFromParentAndCleanup(true);
}
mHeader = header;
// 没有头部,就添加默认的头部
if (mHeader == NULL)
mHeader = createDefaultHead();
if (mHeader)
{
addChild(mHeader);
CCPoint originPos = CCDirector::sharedDirector()->getVisibleOrigin();
CCSize visbleSize = CCDirector::sharedDirector()->getVisibleSize();
mHeader->setPosition(ccp(mWinSize.width/2,originPos.y +visbleSize.height - mHeader->getContentSize().height/2));
//防止头部下边的按钮被点中!! (装备列表)
CCMenuItemImage *headItem = CCMenuItemImage::create(mHeader->getFileName().c_str(), mHeader->getFileName().c_str(), mHeader->getFileName().c_str());
headItem->setOpacity(0);
headItem->setPosition(mHeader->getPosition());
CCMenu *menu = CCMenu::create(headItem, NULL);
// addChild(menu);
menu->setPosition(CCPointZero);
}
}
示例4: clickXilianJingHua
void ZhuangbeiXilianUI::clickXilianJingHua(CCObject *obj)
{
if (m_dInfoDialog)
{
m_dInfoDialog->removeFromParent();
m_dInfoDialog = NULL;
}
string tishiStr = LFStrings::getValue("XilianJingHuaShuoMing");
string cailiaoFileStr = "daoju_youlanzhiye.png";
//弹框背景
BaseSprite* dialog = BaseSprite::create("gongjiang_duanzao_cailiaobuzu_tanchukuang.png");
dialog->setPosition(ccp(mWinSize.width/2, mWinSize.height/2 + 50));
//提示
{
BaseSprite *cailiaoBg = BaseSprite::create("daoju_kuang_bg.png");
dialog->addChild(cailiaoBg);
cailiaoBg->setPosition(ccp(cailiaoBg->getContentSize().width/2 + 10, dialog->getContentSize().height/2));
BaseSprite *cailiaoImg = BaseSprite::create(cailiaoFileStr);
cailiaoBg->addChild(cailiaoImg);
cailiaoImg->setPosition(ccp(cailiaoBg->getContentSize().width/2, cailiaoBg->getContentSize().height/2));
CCLabelTTF* lable = CCLabelTTF::create(tishiStr.c_str(), fontStr_kaiti,20,CCSize(240, 0), kCCTextAlignmentLeft);
dialog->addChild(lable);
lable->setAnchorPoint(ccp(0,0.5));
lable->setPosition(ccp(cailiaoBg->getPositionX()+cailiaoBg->getContentSize().width/2 , dialog->getContentSize().height/2));
}
//按键
CCMenu* menu = CCMenu::create();
{
CCMenuItemImage* item = CCMenuItemImage::create(
"gongjiang_duanzao_cailiaobuzu_tanchukuang.png",
"gongjiang_duanzao_cailiaobuzu_tanchukuang.png",
this, menu_selector(ZhuangbeiXilianUI::clickCiaoliaoShuoMing));
menu->addChild(item);
item->setPosition(ccp(dialog->getContentSize().width/2, dialog->getContentSize().height/2));
item->setOpacity(0);
item->setScaleX(mWinSize.width / dialog->getContentSize().width);
item->setScaleY(mWinSize.height / dialog->getContentSize().height);
// item->setScaleX(mWinSize.width / item->getContentSize().width);
// item->setScaleY(mWinSize.height / item->getContentSize().height);
}
//弹框
{
LFAlert* lfAlert = new LFAlert();
lfAlert->setBaseContainer(dialog,menu);
CCDirector::sharedDirector()->getRunningScene()->addChild(lfAlert,128);
lfAlert->release();
m_dInfoDialog = lfAlert;
}
}
示例5:
CCMenuItemImage* Objects2dFactory::clickableRectangle(CCNode* scene, CCMenu* menu, ccColor3B color, float positionX, float positionY, float width, float height,
SEL_MenuHandler selector, void* selectorArg, AlignX alignX, AlignY alignY, GLubyte opacity, int zOrder)
{
// Check arguments validity
if(scene == NULL || menu == NULL || !selector)
return NULL;
// Create a button menu item
CCMenuItemImage *button = CCMenuItemImage::create("TopQXResources/white.png", "TopQXResources/white.png", "TopQXResources/white.png", scene, selector);
if(!button)
return NULL;
// Set argument
if (selectorArg != NULL)
{
button->setUserData(selectorArg);
}
// Set color
button->setColor(color);
// Set opacity
button->setOpacity(opacity);
// Place the menu item in the given position
button->setPosition(ccp(positionX, positionY));
// Set anchor
button->setAnchorPoint(ccp(Constants::getAnchorValue(alignX), Constants::getAnchorValue(alignY)));
// Set menu item width
float buttonWidth = button->boundingBox().size.width;
button->setScaleX(width / buttonWidth);
// Set menu item height
float buttonHeight = button->boundingBox().size.height;
button->setScaleY(height / buttonHeight);
// Add button to the menu
menu->addChild(button, zOrder);
return button;
}
示例6: selectBlock
void HelloWorld::selectBlock(CCObject* target)
{
// enable pillars
for (int i=0 ; i<3 ; i++)
{
((CCMenuItemImage*)((this->getChildByTag(i))->getChildByTag(i)))->setEnabled(true);
}
// set all block colors to default
for (int x=3 ; x<10 ; x++)
{
((CCMenuItemImage*)((this->getChildByTag(x))->getChildByTag(x)))->setOpacity(255);
}
// set selected block color
CCMenuItemImage* block = (CCMenuItemImage*)(target);
selectedBlock = block->getTag();
block->setOpacity(140);
//CCLog("selectedBlock is %i",selectedBlock);
}
示例7: initCVarAndCCmd
bool ConsoleCocos2dxLayer::init()
{
if (CCLayer::init())
{
// first we create console view
m_consoleView = ConsoleViewCocos2dx::create();
if (!m_consoleView) return false;
m_consoleView->retain();
// then create console controller
m_consoleController = new ConsoleControllerBase();
if (!m_consoleController->Init())
{
CC_SAFE_DELETE(m_consoleController);
return false;
}
// bind view to controller
m_consoleController->SetView(m_consoleView);
// then we create console menu
CCSize visualSize = CCDirector::sharedDirector()->getVisibleSize();
CCMenuItemImage* consoleButton = CCMenuItemImage::create("Console/Terminal.png", "Console/Terminal.png", this, menu_selector(ConsoleCocos2dxLayer::onConsoleButtonClick));
if (!consoleButton) return false;
consoleButton->setScale(0.45f);
consoleButton->setOpacity(128);
consoleButton->setPosition(ccp(visualSize.width * 0.05f, visualSize.height * 0.88f));
CCMenu* consoleMenu = CCMenu::create(consoleButton, NULL);
consoleMenu->setPosition(ccp(0, 0));
consoleMenu->setTouchPriority(kCCMenuHandlerPriority - 2); // NOTE: pay attention to this
addChild(consoleMenu, 1); // NOTE: should at top
// at last, we init cvars and ccmds
// and that's it :)
return initCVarAndCCmd();
}
return false;
}
示例8: init
// on "init" you need to initialize your instance
bool ControlLayer::init()
{
// add a menu item with "X" image, which is clicked to quit the program
// you may modify it.
// add a "close" icon to exit the progress. it's an autorelease object
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
CCMenuItemImage *pCloseItem = CCMenuItemImage::create("CloseNormal.png", "CloseSelected.png",
this,
menu_selector(ControlLayer::menuCloseCallback) );
pCloseItem->setPosition( ccp(winSize.width-20, 20) );
pCloseItem->setScale(0.5);
pCloseItem->setOpacity(200);
// create menu, it's an autorelease object
CCMenu* pMenu = CCMenu::create(pCloseItem, NULL);
pMenu->setPosition( CCPointZero );
this->addChild(pMenu, 1);
CCMenuItemImage *upItem = CCMenuItemImage::create("button.png", "selected.png", this, menu_selector(ControlLayer::Moveup));
CCMenuItemImage *downItem = CCMenuItemImage::create("button.png", "selected.png", this, menu_selector(ControlLayer::Movedown));
CCMenuItemImage *rightItem = CCMenuItemImage::create("button.png", "selected.png", this, menu_selector(ControlLayer::Moveright));
CCMenuItemImage *leftItem = CCMenuItemImage::create("button.png", "selected.png", this, menu_selector(ControlLayer::Moveleft));
int bX; //the x coordination
int bY; //the y coordination
int sizeAdjustionRatioConstant = 3; // for the auto adjusting size
float bScale = winSize.height / (sizeAdjustionRatioConstant * 100); // (screenHeight / buttonHeight) * ratioConstant
int transparence = 30;
bX = (winSize.width / 2);
bY = (winSize.height / 6) * 5;
upItem->setPosition( ccp(bX, bY) );
upItem->setOpacity(transparence);
upItem->setScale(bScale);
bX = (winSize.width / 2);
bY = (winSize.height / 6) * 1;
downItem->setPosition( ccp(bX, bY) );
downItem->setOpacity(transparence);
downItem->setRotation(180);
downItem->setScale(bScale);
bX = (winSize.width / 6) * 5;
bY = (winSize.height / 2);
rightItem->setPosition( ccp(bX, bY) );
rightItem->setOpacity(transparence);
rightItem->setRotation(90);
rightItem->setScale(bScale);
bX = (winSize.width / 6) * 1;
bY = (winSize.height / 2);
leftItem->setPosition( ccp(bX, bY) );
leftItem->setOpacity(transparence);
leftItem->setRotation(270);
leftItem->setScale(bScale);
CCMenu* moveItem = CCMenu::create(upItem, downItem, rightItem, leftItem, NULL);
moveItem->setPosition( CCPointZero );
this->addChild(moveItem, 0);
return true;
}
示例9: CCLOG
bool S65ShowVideo::setUpSubClass2()
{
bool bRet = false;
do
{
scrollMaxSizeY = 0;
CCLayer *pLayer = CCLayer::create();
pLayer->setPosition(CCPointZero);
m_pScrollView = CCScrollView::create();
m_pScrollView->setPosition(ScriptParser::getPositionFromPlist(plistDic, "scrollView"));
m_pScrollView->setContainer(pLayer);
CCSize showSize = ScriptParser::getSizeFromPlist(plistDic, "showSize");
m_pScrollView->setViewSize(CCSizeMake(showSize.width, showSize.height-20));
string str1 = "S"+PersonalApi::convertIntToString(AppDelegate::S1NaviSelected) +"5scrollPic";
string str2 = "S"+PersonalApi::convertIntToString(AppDelegate::S1NaviSelected) +"5VideoIntro";
string str3 = "S"+PersonalApi::convertIntToString(AppDelegate::S1NaviSelected) +"5ScrollBigPic";
showStrUrlMap = PersonalApi::getRealGroupStringMap(plistDic,str2.c_str(),"videoIntro");
showPicMap = PersonalApi::getRealGroupImageMap(plistDic,str1.c_str(),"scrollPic");
showBigPicMap = PersonalApi::getRealGroupImageMap(plistDic,str3.c_str(),"scrollBigPic");
int indexNum = 1;
float elementWidth;
float elementHeight;
int mapSize = showPicMap.size();
int mapSizeRemainder = mapSize%4;
int mapSizeAver;
if (mapSizeRemainder>0) {
mapSizeAver = mapSize/4+1;
}else{
mapSizeAver = mapSize/4;
}
{
const char *imageName = showPicMap[PersonalApi::convertfloatToString(indexNum)].c_str();
string str = PersonalApi::getRealImageName(imageName, "S15Small_1.png").c_str();
CCMenuItemImage * aItemImage = CCMenuItemImage::create(str.c_str(),
str.c_str(),
this,
menu_selector(S65ShowVideo::S15DetailCallback));
elementWidth = aItemImage->getContentSize().width+31;
elementHeight = aItemImage->getContentSize().height+20;
scrollMaxSizeY = elementHeight*mapSizeAver;
}
for (int i = 0; i<(int)showPicMap.size()/4+1; i++){
if (4*(i+1)<=mapSize) {
for (int j = 0; j<4; j++)
{
const char * imageName = showPicMap[PersonalApi::convertIntToString(indexNum)].c_str();
string str=PersonalApi::getRealImageName(imageName,"S15Small_1.png").c_str();
CCLOG("aaaaa%s",str.c_str());
CCMenuItemImage * aItemImage = CCMenuItemImage::create(str.c_str(),
str.c_str(),
this,
menu_selector(S65ShowVideo::S15DetailCallback));
aItemImage->setPosition(ccp(3+145+(aItemImage->getContentSize().width+31)*j,scrollMaxSizeY-elementHeight/2-elementHeight*i));//showSize.height-elementHeight*1.5+(aItemImage->getContentSize().height+20)*i)
FDMenu * detailMenu = FDMenu::create();
detailMenu ->setPosition(CCPointZero);
detailMenu->addChild(aItemImage,zNum);
pLayer->addChild(detailMenu,zNum);
aItemImage->setTag(btnTag+indexNum);
if (i==0&&j<2)
{
aItemImage->setOpacity(1);
}
indexNum++;
}
}else{
for (int j = 0; j<mapSizeRemainder; j++)
{
CCLog("pppppp");
const char * imageName = showPicMap[PersonalApi::convertIntToString(indexNum)].c_str();
string str=PersonalApi::getRealImageName(imageName,"S15Small_1.png").c_str();
// CCLOG("aaaaa%s",str.c_str());
CCMenuItemImage * aItemImage = CCMenuItemImage::create(str.c_str(),
str.c_str(),
this,
menu_selector(S65ShowVideo::S15DetailCallback));
aItemImage->setPosition(ccp(3+145+(aItemImage->getContentSize().width+31)*j,scrollMaxSizeY-elementHeight/2-elementHeight*(i)));//scrollMaxSizeY-elementHeight/2+elementHeight*i) scrollMaxSizeY-elementHeight/2-elementHeight*(mapSizeAver-i-1)
FDMenu * detailMenu = FDMenu::create();
//.........这里部分代码省略.........
示例10: init
bool OverMenu::init(CCNode* layer_)
{
if(!CCLayer::init()){
return false;
}
layer=layer_;
layer->addChild(this,50);
this->schedule(schedule_selector(OverMenu::tick));
int score=((GameLayer*)layer)->gamebody->score;
if(((GameLayer*)layer)->gamebody->game_mode==MODE_SHUANGZI){
score=((GameLayer*)layer)->gamebody->score+((GameLayer*)layer)->gamebody2->score;
}
bool ishigh=false;
int modeid=CCUserDefault::sharedUserDefault()->getIntegerForKey("gamemode");
char modehighscore[200];
sprintf(modehighscore, "highscore%d",modeid);
int highscore=CCUserDefault::sharedUserDefault()->getIntegerForKey(modehighscore);
if(score>highscore){
highscore=score;
CCUserDefault::sharedUserDefault()->setIntegerForKey(modehighscore, highscore);
CCUserDefault::sharedUserDefault()->flush();
ishigh=true;
CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("sound/newscore.mp3", false);
}
{
CCMenuItemImage *button = CCMenuItemImage::create(
"game/black.jpg",
"game/black.jpg",
this,
NULL );
CCMenu* Menu = CCMenu::create(button, NULL);
Menu->setPosition(CCPointZero);
this->addChild(Menu,-1);
button->setAnchorPoint(ccp(0.5f,0));
button->setPosition(ccp(screenSize.width*0.5f,0));
button->setOpacity(150);
}
{
pane=CCSprite::create("over/back.png");
this->addChild(pane,1);
pane->setScale(0.3f*screenSize.height/pane->getContentSize().height);
pane->setPosition(ccpPercent(50, 155));
{
CCMoveTo* a1=CCMoveTo::create(0.4f, ccpPercent(50, 60));
pane->runAction(a1);
}
{
CCLabelTTF* word = CCLabelTTF::create("游戏结束", "ttf/word.ttf", pane->getContentSize().height*0.2f);
word->setAnchorPoint(ccp(0.5f,0.5f));
pane->addChild(word, 10);
word->setPosition(ccpContent(pane->getContentSize(), 50, 120));
word->setColor(ccGRAY);
}
{
char* name;
GAME_MODE gamemode=((GameLayer*)layer)->game_mode;
char* gamecenterid;
if(gamemode==MODE_WANMEI){
name=(char*)"完美模式";
gamecenterid=(char*)"com.adultdream.mengmengda.wanmei";
}
if(gamemode==MODE_SHANDIAN){
name=(char*)"闪电模式";
gamecenterid=(char*)"com.adultdream.mengmengda.shandian";
}
if(gamemode==MODE_NIUZHUAN){
name=(char*)"扭转模式";
gamecenterid=(char*)"com.adultdream.mengmengda.niuzhuan";
}
if(gamemode==MODE_SHUANGZI){
name=(char*)"双子模式";
gamecenterid=(char*)"com.adultdream.mengmengda.shuangzi";
}
if(gamemode==MODE_XIANSHI){
name=(char*)"限时模式";
gamecenterid=(char*)"com.adultdream.mengmengda.xianshi";
}
if(gamemode==MODE_JINGDIAN){
name=(char*)"经典模式";
gamecenterid=(char*)"com.adultdream.mengmengda.jingdian";
}
CCLabelTTF* word = CCLabelTTF::create(name, "ttf/word.ttf", pane->getContentSize().height*0.15f);
word->setAnchorPoint(ccp(0.5f,0.5f));
pane->addChild(word, 10);
word->setPosition(ccpContent(pane->getContentSize(), 50, 80));
//.........这里部分代码省略.........