axmol/samples/Cpp/TestCpp/Classes/BugsTest/Bug-458/Bug-458.cpp

47 lines
1.5 KiB
C++
Raw Normal View History

2011-07-08 11:22:35 +08:00
//
// Bug-458 test case by nedrafehi
// http://code.google.com/p/cocos2d-iphone/issues/detail?id=458
//
#include "Bug-458.h"
#include "QuestionContainerSprite.h"
bool Bug458Layer::init()
{
if(BugsTestBaseLayer::init())
{
// ask director the the window size
2011-07-08 11:22:35 +08:00
CCSize size = CCDirector::sharedDirector()->getWinSize();
QuestionContainerSprite* question = new QuestionContainerSprite();
QuestionContainerSprite* question2 = new QuestionContainerSprite();
question->init();
question2->init();
// [question setContentSize:CGSizeMake(50,50)];
// [question2 setContentSize:CGSizeMake(50,50)];
CCMenuItemSprite* sprite = CCMenuItemSprite::create(question2, question, CALLBACK_1(Bug458Layer::selectAnswer, this) );
CCLayerColor* layer = CCLayerColor::create(ccc4(0,0,255,255), 100, 100);
question->release();
question2->release();
2011-07-08 11:22:35 +08:00
CCLayerColor* layer2 = CCLayerColor::create(ccc4(255,0,0,255), 100, 100);
CCMenuItemSprite* sprite2 = CCMenuItemSprite::create(layer, layer2, CALLBACK_1(Bug458Layer::selectAnswer, this) );
CCMenu* menu = CCMenu::create(sprite, sprite2, NULL);
2011-07-08 11:22:35 +08:00
menu->alignItemsVerticallyWithPadding(100);
menu->setPosition(ccp(size.width / 2, size.height / 2));
// add the label as a child to this Layer
addChild(menu);
2011-07-08 11:22:35 +08:00
return true;
}
return false;
2011-07-08 11:22:35 +08:00
}
void Bug458Layer::selectAnswer(CCObject* sender)
{
CCLog("Selected");
}