本文整理汇总了C++中CCMenuItemImage::setRotation方法的典型用法代码示例。如果您正苦于以下问题:C++ CCMenuItemImage::setRotation方法的具体用法?C++ CCMenuItemImage::setRotation怎么用?C++ CCMenuItemImage::setRotation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCMenuItemImage
的用法示例。
在下文中一共展示了CCMenuItemImage::setRotation方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: menuPlayCallback
void MainMenu::menuPlayCallback(CCObject* pSender){
//CCDirector *director = CCDirector::sharedDirector();
//director->replaceScene(MainMenu::scene());
//remove background and apply a new one (not necesary)
this->removeChild(background1);
this->removeChild(pMenu);
//add new background
background2 = CCSprite::create("pixelGrid.png");
background2->setAnchorPoint(ccp(0,1));
background2->setPosition(ccp(-50, _screenSize.height+45));
this->addChild(background2, 1);
CCMenuItemImage *farmSceneItem = CCMenuItemImage::create("scenePreview1.png","scenePreview1.png",this,
menu_selector(MainMenu::farmSceneCallback) );
//farmSceneItem->setAnchorPoint(ccp(0,0));
farmSceneItem->setPosition(ccp(_screenSize.width*0.30,_screenSize.height*0.70));
//OPTION BUTTON
CCMenuItemImage *jungleSceneItem = CCMenuItemImage::create("scenePreview2.png","scenePreview2.png",this,
menu_selector(MainMenu::jungleSceneCallback) );
jungleSceneItem->setPosition(ccp(_screenSize.width*0.70,_screenSize.height*0.70));
//jungleSceneItem->setRotation(90);
//jungleSceneItem->setAnchorPoint(ccp(0,0));
CCMenuItemImage *northPoleSceneItem = CCMenuItemImage::create("scenePreview3.png","scenePreview3.png",this,
menu_selector(MainMenu::northPoleSceneCallback) );
northPoleSceneItem->setPosition(ccp(_screenSize.width*0.30,_screenSize.height*0.30));
//northPoleSceneItem->setAnchorPoint(ccp(0,0));
CCMenuItemImage *citySceneItem = CCMenuItemImage::create("scenePreview4.png","scenePreview4.png",this,
menu_selector(MainMenu::citySceneCallback) );
citySceneItem->setPosition(ccp(_screenSize.width*0.70,_screenSize.height*0.30));
//citySceneItem->setAnchorPoint(ccp(0,0));
CCMenuItemImage *backButtonItem = CCMenuItemImage::create("arrowButton.png","arrowButton.png",this,
menu_selector(MainMenu::backButtonCallback) );
backButtonItem->setPosition(ccp(_screenSize.width*0.50,_screenSize.height*0.10));
backButtonItem->setRotation(180);
backButtonItem->setScale(1.5);
//Create menu, it's an autorelease object
sceneMenu = CCMenu::create(farmSceneItem,jungleSceneItem,northPoleSceneItem,citySceneItem,backButtonItem, NULL);
sceneMenu->setPosition( CCPointZero );
this->addChild(sceneMenu, 2);
sceneMenu->retain();
/*
//Add select button
playButton = CCSprite::createWithSpriteFrameName("selectButton.png");
playButton->setPosition(ccp(_screenSize.width*0.90,_screenSize.height*0.10));
this->addChild(playButton,2);
//Add next button
nextButton = CCSprite::createWithSpriteFrameName("arrowButton.png");
nextButton->setPosition(ccp(_screenSize.width*0.90,_screenSize.height*0.50));
this->addChild(nextButton,2);
//Add previous button
previousButton = CCSprite::createWithSpriteFrameName("arrowButton.png");
previousButton->setPosition(ccp(_screenSize.width*0.10,_screenSize.height*0.50));
previousButton->setRotation(180);
this->addChild(previousButton,2);
//Add back button
backButton = CCSprite::createWithSpriteFrameName("selectButton.png");
backButton->setPosition(ccp(_screenSize.width*0.10,_screenSize.height*0.10));
backButton->setRotation(180);
this->addChild(backButton,2);
//THIS WILL BE A SPRITESHEET TO MINIMIZE IMAGE GRABS IN THE FUTURE
//add scene preview
CCSprite * sprite;
scenePreview = CCArray::createWithCapacity(numberOfScenes); //there are only 4 scenes
scenePreview->retain();
sprite = CCSprite::create("menuScenePreview.png");
sprite->setPosition(ccp(_screenSize.width*.50, _screenSize.height*.50));
//this->addChild(scenePreview, 3);
scenePreview
*/
}