LayerColor * LayerColor::create(const Color4B& color, GLfloat width, GLfloat height) { LayerColor * layer = new LayerColor(); if( layer && layer->initWithColor(color,width,height)) { layer->autorelease(); return layer; } CC_SAFE_DELETE(layer); return nullptr; }
LayerColor * LayerColor::create(const Color4B& color) { LayerColor * layer = new (std::nothrow) LayerColor(); if(layer && layer->initWithColor(color)) { layer->autorelease(); return layer; } CC_SAFE_DELETE(layer); return nullptr; }
// on "init" you need to initialize your instance bool MainLoadingScene::init() { if ( !Scene::init() ) { return false; } LayerColor *layer = LayerColor::create(); layer->initWithColor(Color4B(255, 255, 255, 255), VisibleRect::right().x , VisibleRect::top().y); layer->setPosition(VisibleRect::center()); layer->setAnchorPoint(Vec2(0.5f, 0.5f)); layer->setIgnoreAnchorPointForPosition(false); this->addChild(layer, 0); Sprite *fondo = Sprite::create("fondo.png"); fondo->setPosition(VisibleRect::center()); this->addChild(fondo); Sprite *sprite = Sprite::create("logo.png"); sprite->setPosition(VisibleRect::center()); this->addChild(sprite); Label *progress = Label::createWithTTF ("Kargatzen ari da.\nMesedez, minutu pare bat itxaron.", "fonts/PT_Sans-Web-Regular.ttf", 10); progress->setPosition(Vec2(VisibleRect::center().x, VisibleRect::bottom().y + 12)); progress->setAnchorPoint(Vec2(0.5,0.5)); progress->setColor(Color3B(0,0,0)); addChild(progress); loading = Sprite::create("loading.png"); loading->setPosition(Vec2(VisibleRect::center().x, VisibleRect::bottom().y + progress->getContentSize().height + loading->getContentSize().height / 2)); addChild(loading); ActionInterval* rotate = RotateBy::create(5.0f, 360.0f); RepeatForever *repeat = RepeatForever::create(rotate); loading->runAction(repeat); return true; }