//纯色色块控件(锚点默认左下角)
CCLayerColor* ccc = CCLayerColor::create(ccc4(255, 0, 0, 128), 200, 100);
//渐变色块控件
CCLayerGradient* ccc = CCLayerGradient::create(ccc4(255, 0, 0, 255), ccc4(255, 255, 0, 255), ccp(1, 1));
ccc->changeWidth(400); //改变宽度
ccc->changeHeight(200); //改变高度
ccc->changeWidthAndHeight(400,200); //同时改变宽高
ccc->setColor(ccc3(0, 255, 0)); //设置颜色
ccc->setOpacity(255); //设置透明度
this->addChild(ccc);
//文本控件
CCLabelTTF* label = CCLabelTTF::create("Hello, I'm a good student, I like com", "Microsoft Yahei", 50, CCSize(240, 320), kCCTextAlignmentLeft, kCCVerticalTextAlignmentCenter);
//菜单绑定
CCLabelTTF* label1 = CCLabelTTF::create("Start", "Microsoft Yahei", 50); label1->setColor(ccc3(255, 255, 0));
CCLabelTTF* label2 = CCLabelTTF::create("Exit", "Microsoft Yahei", 50); label2->setColor(ccc3(255, 255, 0));
//文本菜单项
CCMenuItemLabel* mil1 = CCMenuItemLabel::create(label1);
mil1->setPosition(ccp(240, 160));
CCMenuItemLabel* mil2 = CCMenuItemLabel::create(label2);
mil2->setPosition(ccp(240, 100));
//图片菜单项
CCMenuItemImage* mii1 = CCMenuItemImage::create();
CCMenu* menu = CCMenu::create(mil1, mil2, NULL);
menu->setPosition(ccp(0, 0));
this->addChild(menu);
//--------------------------------------------------------------------------------
//播放帧动画
//方法一
CCSpriteFrame* frame1 = CCSpriteFrame::create("menu/logo/1.png", CCRectMake(0, 0, 240, 190));
CCSpriteFrame* frame2 = CCSpriteFrame::create("menu/logo/2.png", CCRectMake(0, 0, 240, 190));
CCSpriteFrame* frame3 = CCSpriteFrame::create("menu/logo/3.png", CCRectMake(0, 0, 240, 190));
CCArray* frames = CCArray::create(frame1, frame2, frame3, NULL); CCAnimation* animation = CCAnimation::createWithSpriteFrames(frames, 1/20.0);
CCAnimate* animate = CCAnimate::create(animation);
CCSprite* sprite = CCSprite::create();
CCSprite* sprite = CCSprite::create();
sprite->setPosition(ccp(240, 160));
this->addChild(sprite);
sprite->runAction(CCRepeatForever::create(animate));
//方法二
this->regPlay(); //注册动画
CCAnimation* animation1 = CCAnimationCache::sharedAnimationCache()->animationByName("play_logo");
CCSprite* sprite = CCSprite::create();
sprite->setPosition(ccp(240, 160));
this->addChild(sprite);
sprite->runAction(CCRepeatForever::create(animation1));
void HelloWorldScene::regPlay()
{
CCSpriteFrame* frame1 = CCSpriteFrame::create("menu/logo/1.png", CCRectMake(0, 0, 240, 190));
CCSpriteFrame* frame2 = CCSpriteFrame::create("menu/logo/2.png", CCRectMake(0, 0, 240, 190));
CCSpriteFrame* frame3 = CCSpriteFrame::create("menu/logo/3.png", CCRectMake(0, 0, 240, 190));
CCArray* frames = CCArray::create(frame1, frame2, frame3, NULL);
CCAnimation* animation = CCAnimation::createWithSpriteFrames(frames, 1/20.0);
CCAnimationCache::sharedAnimationCache()->addAnimation(animation,"play_logo");
}