#include "HelloWorldScene.h"
HelloWorld::HelloWorld()
{
}
HelloWorld::~HelloWorld()
{
}
Scene* HelloWorld::createScene()
{
auto scene = Scene::create();
auto layer = HelloWorld::create();
scene->addChild(layer);
return scene;
}
bool HelloWorld::init()
{
if ( !Layer::init() )
{
return false;
}
auto visibleSize = Director::getInstance()->getVisibleSize();
/************************************************************************/
/*
Sprite */
/************************************************************************/
Sprite* pLayerBg = Sprite::create("123.png");
//Sprite* pLayerBg = Sprite::createWithSpriteFrameName("123.png");
pLayerBg->setPosition(Vec2(480.f, 320.f));
pLayerBg->setAnchorPoint(Vec2(0.f, 1.f));
pLayerBg->setTextureRect(Rect(0,0,100,100));
pLayerBg->setScaleX(200.f / pLayerBg->getContentSize().width);//宽200;
pLayerBg->setScaleY(200.f / pLayerBg->getContentSize().height);//高200;
pLayerBg->setScale(0.8f);
pLayerBg->setVisible(true);
pLayerBg->setZOrder(1);
pLayerBg->setCascadeOpacityEnabled(true);//打开透明度;
pLayerBg->setOpacity(123);
pLayerBg->setTexture("OtherImage.bundle/Champion/cp_equip_0.png");//本地文件获取;
pLayerBg->setSpriteFrame("123.png");//参数为spriteFrameName plist文件获取;
pLayerBg->setSpriteFrame(SpriteFrameCache::getInstance()->getSpriteFrameByName("132.png"));//参数为spriteFrame plist文件获取;等价于Sprite::createWithSpriteFrameName("123.png");
//pLayerBg->setSpriteFrame(Sprite::create("OtherImage.bundle/Champion/cp_equip_0.png")->getSpriteFrame());//参数为spriteFrame 本地文件获取;
this->addChild(pLayerBg, 0);
pLayerBg->runAction(RepeatForever::create(RotateBy::create(2.f, 360)));
pLayerBg->removeFromParentAndCleanup(true);
pLayerBg = NULL;
pLayerBg->stopAllActions();
pLayerBg->setRotation(0.f);
bool isEqual = pLayerBg->getResourceName().compare("123.png") != 0;
Rect tempRc = pLayerBg->getTextureRect();
/************************************************************************/
/*
Label */
/************************************************************************/
auto _labelDownStatus = Label::create("", "Arial", 20);
//auto _labelDownStatus = Label::create("", "", 20, Size(800.f, 150.f), TextHAlignment::LEFT, TextVAlignment::TOP);
_labelDownStatus->setColor(Color3B::YELLOW);
_labelDownStatus->setTextColor(Color4B::YELLOW);
_labelDownStatus->setString("1323");
_labelDownStatus->setOpacity(120);
_labelDownStatus->enableShadow(Color4B(0, 0, 0, 100), Size(1, -1));
_labelDownStatus->enableOutline(Color4B(0, 40, 50, 255), 2);
_labelDownStatus->setPosition(Vec2(480.f, 120.f));
_labelDownStatus->setMaxLineWidth(140);
_labelDownStatus->setDimensions(480, 80);
_labelDownStatus->setLineBreakWithoutSpace(false);
_labelDownStatus->setWidth(500);
_labelDownStatus->setRotationSkewY(180.f);
_labelDownStatus->setAlignment(TextHAlignment::CENTER, TextVAlignment::CENTER);
_labelDownStatus->setVerticalAlignment(TextVAlignment::CENTER);
_labelDownStatus->setHorizontalAlignment(TextHAlignment::CENTER);
this->addChild(_labelDownStatus, 2);
_labelDownStatus->runAction(Sequence::create(DelayTime::create(3.f), RemoveSelf::create(), NULL));
/************************************************************************/
/*
Label */
/************************************************************************/
//字体数字;
auto textatlas = Label::createWithCharMap("OtherImage.bundle/Num/public_num.png", 30, 34, ',');
textatlas->setAnchorPoint(Vec2::ANCHOR_MIDDLE_LEFT);
textatlas->setSkewX(15);
textatlas->setPosition(Vec2(650, 35));
this->addChild(textatlas);
/************************************************************************/
/*
LabelAtlas */
/************************************************************************/
//字体数字;
auto scoreLabel = LabelAtlas::create("0","OtherImage.bundle/Num/Desk_Score_Num.png", 38, 60, '/');
scoreLabel->setAnchorPoint(Vec2(0.5f, 0.5f));
scoreLabel->setScale(0.5f);
scoreLabel->setPosition(_labelDownStatus->getPosition());
this->addChild(scoreLabel, 15);
/************************************************************************/
/*
ProgressTimer */
/************************************************************************/
auto _downProgress = ProgressTimer::create(Sprite::create("1132.png"));
_downProgress->setType(ProgressTimer::Type::BAR);
_downProgress->setPosition(Vec2(480.f, 80.f));
_downProgress->setMidpoint(Vec2(0, 0));
_downProgress->setBarChangeRate(Vec2(1, 0));
_downProgress->setReverseDirection(true);
_downProgress->setPercentage(0);
this->addChild(_downProgress, 2);
_downProgress->runAction(Sequence::create(ProgressFromTo::create(10.f, 20, 30), NULL));//从哪里滚动到哪里;
_downProgress->runAction(Sequence::create(ProgressTo::create(10.f,30), NULL));//滚动到哪里;
/************************************************************************/
/*
Scale9Sprite */
/************************************************************************/
auto _loadBg = ui::Scale9Sprite::createWithSpriteFrameName("Public_Tip_Bg.png");
//auto _loadBg = ui::Scale9Sprite::create("OtherImage.bundle/OtherImg/Eq_Black.png", Rect(0, 0, 50, 50), Rect(20, 20, 10, 10));
_loadBg->setCapInsets(Rect(30.f, 30.f, 40.f, 40.f));
_loadBg->setContentSize(Size(100.f, 46.f));
_loadBg->setPosition(Vec2(480.f, 100.f));
this->addChild(_loadBg, 0);
/************************************************************************/
/*
MenuItemSprite */
/************************************************************************/
ui::Scale9Sprite* bt1Normal = ui::Scale9Sprite::createWithSpriteFrameName("p_green_btn_n.png");
bt1Normal->setContentSize(Size(240.f, 66.f));
ui::Scale9Sprite* bt1Press = ui::Scale9Sprite::createWithSpriteFrameName(("p_green_btn_p.png"));
bt1Press->setContentSize(Size(240.f, 66.f));
//Sprite* bt1Normal = Sprite::createWithSpriteFrameName("p_green_btn_n.png");
//Sprite* bt1Press = Sprite::createWithSpriteFrameName(("p_green_btn_p.png"));
//第一种;
MenuItemSprite* offlineMenu = MenuItemSprite::create(bt1Normal, bt1Press, CC_CALLBACK_1(HelloWorld::menuCallBack, this));
offlineMenu->setAnchorPoint(Vec2(1.f, 1.f));
offlineMenu->setPosition(Vec2(480.f,320.f));
//offlineMenu->setNormalImage(Sprite::createWithSpriteFrameName("DeskGame_Cue_Small_Normal.png"));
//offlineMenu->setSelectedImage(Sprite::createWithSpriteFrameName("DeskGame_Cue_Small_Press.png"));
offlineMenu->setEnabled(false);
offlineMenu->selected();
//offlineMenu->setEnabled(true);
//offlineMenu->unselected();
auto _TopMenu = Menu::createWithItem(offlineMenu);
_TopMenu->setPosition(Vec2(0.f, 300.f));
this->addChild(_TopMenu);
//第二种;
Vector