Esempio n. 1
0
void PadControlLayer::initSprite()
{
    velocity = Vec2::ZERO;
    isPressed = false;
    isButtonA = false;
    isButtonB = false;
    isStart = false;
    isSelect = false;
    
    float factor = 1.5;
    float JoySize = _visibleSize.height*124.8*factor/720;      // 124.8
    
    float edgeLong =  _visibleSize.height* 100*factor/720;   // 100
    kCenter = Vec2( edgeLong, edgeLong );
    _JOYSTICK_RADIUS = edgeLong;
    _THUMB_RADIUS = _visibleSize.height*20.0*factor/720;
    
    joystickBackground = Sprite::create("gamepad/ThumbPadRing.png");
    joystickBackground->setScale( JoySize/78 );
    joystickBackground->setPosition(kCenter);
    this->addChild(joystickBackground,0);
    
    float thumbSize = _visibleSize.height*57.6*factor/720;
    thumbPad = Sprite::create("gamepad/ThumbPad.png");
    thumbPad->setScale(thumbSize/64);
    thumbPad->setPosition(kCenter);
    this->addChild(thumbPad,1);
    
    float thumbab = _visibleSize.height*64*factor/720;
    buttonA = Sprite::create("gamepad/ButtonA.png");
    buttonA->setScale(thumbab/64);
    buttonA->setPosition(Vec2(_visibleSize.width - _visibleSize.height*160*factor/720, _visibleSize.height*80*factor/720));
    this->addChild(buttonA,1);
    
    buttonB = Sprite::create("gamepad/ButtonB.png");
    buttonB->setScale(thumbab/64);
    buttonB->setPosition(Vec2(_visibleSize.width - _visibleSize.height*70*factor/720, _visibleSize.height*115*factor/720));
    this->addChild(buttonB,1);
    
    float startSize = _visibleSize.width*130/1280;
    MenuItemImage *start = MenuItemImage::create("gamepad/start.png", "gamepad/start.png", CC_CALLBACK_1(PadControlLayer::nesStart, this));
    start->setScale(startSize/600);
    start->setPosition(_visibleSize.width - _visibleSize.width*100/1280, _visibleSize.height /2);
    
    MenuItemImage *select = MenuItemImage::create("gamepad/select.png", "gamepad/select.png", CC_CALLBACK_1(PadControlLayer::nesSelect, this));
    select->setScale(startSize/600);
    select->setPosition(_visibleSize.width - _visibleSize.width*100/1280, _visibleSize.height /2 - _visibleSize.height *70/720);
    
    float nesCardSize = _visibleSize.height*65/720;
    MenuItemImage *nescard = MenuItemImage::create("gamepad/nescard.png", "gamepad/nescard.png", CC_CALLBACK_1(PadControlLayer::nesSelectGame, this));
    nescard->setScale(nesCardSize/200);
    nescard->setPosition(Vec2(_visibleSize.width*50/1280, _visibleSize.height - _visibleSize.height*50/720));
    
    Menu *menu1 = Menu::create(start, select, nescard ,NULL);
    menu1->setPosition(Vec2::ZERO);
    this->addChild(menu1,1);
}
Esempio n. 2
0
bool GameMenu::init()
{
    if (!Layer::init()) {
        return false;
    }
    
    Size size = Director::getInstance()->getWinSize();
    LayerColor *layerColor = LayerColor::create(Color4B(223, 253, 253, 255), size.width, size.height);
    this->addChild(layerColor);
    
//    Label *label = Label::createWithBMFont("fonts.fnt", "Miku Run");
//    label->setScale(0.7);
//    label->setPosition(Point(130, size.height-50));
//    this->addChild(label);
    
    MenuItemImage *startItem = MenuItemImage::create("bird_start_btn.png", "brid_start_btn_pressed.png",CC_CALLBACK_1(GameMenu::startGame, this));
    startItem->setScale(1.5);
    
    auto menu = Menu::create(startItem,NULL);
    menu->alignItemsVerticallyWithPadding(20);
    //menu->alignItemsHorizontallyWithPadding(50);
    menu->setPosition(Point(160,size.height/2));
    this->addChild(menu, 1);
    
    return true;
}
Esempio n. 3
0
void UI::createLevelEditorFilePopup()
{
	Size visibleSize = Director::getInstance()->getVisibleSize();

	MenuItemFont* addTextureObject = MenuItemFont::create("choose file", CC_CALLBACK_0(UI::nullCallback, this));
	addTextureObject->setFontNameObj("Segoe UI");
	addTextureObject->setFontSizeObj(34);
	addTextureObject->setPosition(visibleSize.width * 0.5f, visibleSize.height - 30);

	MenuItemFont* scrollUpObject = MenuItemFont::create("up", CC_CALLBACK_0(LevelEditor::moveFileSelectUpCallback, pLevelEditor));
	scrollUpObject->setFontNameObj("Segoe UI");
	scrollUpObject->setFontSizeObj(34);
	scrollUpObject->setPosition(visibleSize.width - 50, visibleSize.height - 30);

	MenuItemFont* scrollDownObject = MenuItemFont::create("down", CC_CALLBACK_0(LevelEditor::moveFileSelectDownCallback, pLevelEditor));
	scrollDownObject->setFontNameObj("Segoe UI");
	scrollDownObject->setFontSizeObj(34);
	scrollDownObject->setPosition(visibleSize.width - 50, 30);

	MenuItemImage* scrollBackground = MenuItemImage::create("Resources/pictures/generic/ui_background.png", "ui_background.png", CC_CALLBACK_0(UI::nullCallback, this));
	scrollBackground->setPosition(visibleSize.width * 0.5f, visibleSize.height * 0.5f);
	scrollBackground->setScale(400, visibleSize.height);

	int paddingTop = 60;
	Vector<MenuItem*> lMenuItems;
	lMenuItems.pushBack(addTextureObject);
	for (string s : getAllFilesInFolder("Resources/pictures/tiles"))
	{
		MenuItemFont* menuItem = MenuItemFont::create(s, CC_CALLBACK_1(LevelEditor::chooseFileCallback, pLevelEditor, s, levelType));
		menuItem->setFontNameObj("Segoe UI");
		menuItem->setFontSizeObj(24);
		menuItem->setPosition(visibleSize.width * 0.5f, visibleSize.height - paddingTop);
		paddingTop += 30;
		lMenuItems.pushBack(menuItem);
	}
	auto menu = Menu::createWithArray(lMenuItems);
	auto scrollMenu = Menu::create(scrollBackground, scrollDownObject, scrollUpObject, NULL);
	scrollMenu->retain();
	scrollMenu->setPosition(0, 0);
	menu->retain();
	menu->setPosition(0, 0);
	m_pLevelEditor->addChild(menu);
	m_pLevelEditor->addChild(scrollMenu, -10);
	pLevelEditor->ChooseFileMenu = menu;
	pLevelEditor->ChooseFileNavMenu = scrollMenu;
}
Esempio n. 4
0
bool GameMain::init()
{
    if ( !Layer::init() )
    {
        return false;
    }
    
    Size size = Director::getInstance()->getWinSize();
    map = new GameObjMap();
    map->setAnchorPoint(Point(0,1));
    map->setPosition(Point(0,size.height));
    addChild(map,0);
    hero = new GameObjHero();
    //hero->setScale(0.5);
    //hero->setPosition(Point(100,160));
    hero->setPosition(Point(100,350));
    addChild(hero,1);
    gamemark = new GameMark();
    addChild(gamemark,4);
    gamemark = new GameMark();
    addChild(gamemark,4);
    gameover = Sprite::create("gameover.png");
    gameover->setAnchorPoint(Point(0.5,0.5));
    gameover->setPosition(Point(0,0));
    gameover->setPosition(Point(size.width/2,size.height/2 + 70));
    gameover->setVisible(false);
    //gameover->setScale(0.5);
    addChild(gameover,5);
    MenuItemImage *pCloseItem = MenuItemImage::create("back.png","back.png",CC_CALLBACK_1(GameMain::menuBackCallback, this));
    pCloseItem->setPosition( Point(size.width/2,size.height/2 - 50) );
    pCloseItem->setScale(0.5);
    Menu* pMenu = Menu::create(pCloseItem, NULL);
    pMenu->setPosition( Point::ZERO);
    this->addChild(pMenu,5,25);
    pMenu->setVisible(false);
    pMenu->setEnabled(false);
    isover = false;
    scheduleUpdate();
    return true;
}
bool ManagerToUserSettingsLayer::init(IOnGoalChangedForUser *delegate, const std::string &userId, int goal) {
    if(!Layer::init()) {
        return false;
    }

    _goalChangedDelegate = delegate;
    _userId = userId;
    _userGoal = goal;

    Size visibleSize = Director::getInstance()->getVisibleSize();

    // back
    {
        _back = Sprite::create("back.png");
        _back->setPosition({static_cast<float>(visibleSize.width / 2.0), static_cast<float>(visibleSize.height / 2.0)});

        Size backSize = _back->getContentSize();

        _back->setScale(visibleSize.width / backSize.width, visibleSize.height / backSize.height);

        this->addChild(_back, zBack);
    }

    {
        // parent blocker
        MenuItemImage *btn = MenuItemImage::create("blank.png", "blank.png", [](Ref *) {});
        btn->setScale(visibleSize.width / btn->getContentSize().width, visibleSize.height / btn->getContentSize().height);
        btn->setOpacity(0);

        Menu *blockMenu = Menu::create(btn, nullptr);
        blockMenu->setPosition({visibleSize.width * 0.5f, visibleSize.height * 0.5f});

        this->addChild(blockMenu);
    }

    {
        // heading
        _mntHeading = Sprite::create("mnt_settings_heading.png");
        _mntHeading->setAnchorPoint({0.5f, 1.0f});
        _mntHeading->setPosition({visibleSize.width * 0.5f, visibleSize.height});

        this->addChild(_mntHeading);

        // back button
        _btnBack = MenuItemImage::create("btn_back.png", "btn_back_on.png", CC_CALLBACK_0(ManagerToUserSettingsLayer::onBtnBackPressed, this));
        _btnBack->setAnchorPoint({0, 1});
        _btnBack->setPosition({0, visibleSize.height});

        Menu *backMenu = Menu::create(_btnBack, nullptr);
        backMenu->setPosition({0, 0});

        this->addChild(backMenu);
    }

    {
        // save button
        _btnSave = MenuItemImage::create("btn_settings_save.png", "btn_settings_save_on.png", CC_CALLBACK_0(ManagerToUserSettingsLayer::onBtnSavePressed, this));
        _btnSave->setAnchorPoint({0.5f, 0});
        _btnSave->setPosition({visibleSize.width * 0.5f, 0});

        Menu *saveMenu = Menu::create(_btnSave, nullptr);
        saveMenu->setPosition({0, 0});

        this->addChild(saveMenu);
    }

    {
        // a slider
        _sliderGroupNode = Node::create();
        _sliderGroupNode->setPosition({visibleSize.width * 0.5f, visibleSize.height * 0.5f + _btnSave->getContentSize().height * 0.5f});

        this->addChild(_sliderGroupNode);

        _sliderCalories = ControlSlider::create("mnt_settings_calories_slider.png", "settings_calories_slider.png", "settings_calories_slider_thumb.png");
        _sliderCalories->addTargetWithActionForControlEvents(this, cccontrol_selector(ManagerToUserSettingsLayer::onSliderCaloriesChanged),
                Control::EventType::VALUE_CHANGED);
        _sliderCalories->setMaximumAllowedValue(1);
        _sliderCalories->setMinimumAllowedValue(0.1);

        _sliderGroupNode->addChild(_sliderCalories);
    }

    {
        // captions
        _labelSliderCaption = Label::createWithTTF("Daily goal", "helvetica.ttf", 26);
        _labelSliderCaption->setColor({53, 172, 225});
        _labelSliderCaption->setAnchorPoint({0, 0.0});
        _labelSliderCaption->setPosition({-_sliderCalories->getContentSize().width * 0.5f, _labelSliderCaption->getContentSize().height});

        _sliderGroupNode->addChild(_labelSliderCaption);
    }

    {
        _labelCaloriesToConsumeCaption = Label::createWithTTF("10000", "helvetica.ttf", 25);
        _labelCaloriesToConsumeCaption->setColor({93, 93, 93});
        _labelCaloriesToConsumeCaption->setOpacity(0.7f * 255);
        _labelCaloriesToConsumeCaption->setAnchorPoint({0.5, 1});
        _labelCaloriesToConsumeCaption->setPosition({0, -_labelCaloriesToConsumeCaption->getContentSize().height});

        _sliderGroupNode->addChild(_labelCaloriesToConsumeCaption);

        _sliderCalories->setValue(1.0f * _userGoal / kMaxKCaloriesPerDay);
    }

    return true;
}
Esempio n. 6
0
bool HelloInputLayer::init()
{

	IsLeiHelpDown = false;
	
	
	IsLeiShopDown = false ;
	

	IsLeiAboutUsDown = false ; 
	
	Sprite* menulist = Sprite::create();
	menulist->setPosition(1500,600);
	MoveBy* c = MoveBy::create(3.0f,Point(-425,0));
	Action* t = EaseExponentialOut::create(c);
	menulist->runAction(t);
	this->addChild(menulist);

	Size winSize = Director::getInstance()->getWinSize();
	MenuItemImage *menuNewGame = MenuItemImage::create("img/Lei/new game 1.png", "img/lei/new game 2.png",CC_CALLBACK_1(HelloInputLayer::StartCallback,this));
	menuNewGame->setPosition(Point(40, 0));
	menuNewGame->setScale(0.75f,0.75f);
	MenuItemImage *menuQuitGame = MenuItemImage::create("img/Lei/exit 1.png", "img/Lei/exit 2.png",CC_CALLBACK_1(HelloInputLayer::menuCloseCallback,this));
	menuQuitGame->setPosition(Point(0, -375));
	menuQuitGame->setScale(0.75f,0.75f);
	MenuItemImage *menuShop = MenuItemImage::create("img/Lei/shop 1.png","img/Lei/shop 2.png",CC_CALLBACK_1(HelloInputLayer::menuShopCallback,this));
	menuShop->setPosition(Point(100, -125));
	menuShop->setScale(0.75f,0.75f);
	MenuItemImage *menuHelp = MenuItemImage::create("img/Lei/help 1.png","img/Lei/help 2.png",CC_CALLBACK_1(HelloInputLayer::menuHelpCallback,this));
	menuHelp->setPosition(Point(120, -250));
	menuHelp->setScale(0.75f,0.75f);
	
	Menu *menu = Menu::create(menuNewGame,menuHelp,menuShop,menuQuitGame, NULL);
	menu->setPosition(0,0);
	menulist->addChild(menu);


	MenuItemImage *menuAboutUsItem = MenuItemImage::create("img/Lei/word_ABOUTUS.png","img/Lei/word_ABOUTUS.png",CC_CALLBACK_1(HelloInputLayer::menuAboutUsCallback,this));
	menuAboutUsItem->setPosition(Point(0, 0));
	
	Menu *menuAboutUs = Menu::create(menuAboutUsItem,NULL);
	menuAboutUs->setPosition(1300,60);
	this->addChild(menuAboutUs);


	MenuItemImage *menuSelectLeft= MenuItemImage::create("img/Lei/button_left.png","img/Lei/button_left_2.png",CC_CALLBACK_1(HelloInputLayer::menuSelectLeftCallback,this));
	menuSelectLeft->setPosition(Point(0, 0));
	MenuItemImage *menuSelectRight= MenuItemImage::create("img/Lei/button_right.png","img/Lei/button_right_2.png",CC_CALLBACK_1(HelloInputLayer::menuSelectRightCallback,this));
	menuSelectRight->setPosition(Point(132,3));
	Menu *menuSelectFlight = Menu::create(menuSelectLeft,menuSelectRight,NULL);
	menuSelectFlight->setPosition(Point(300,100));
	this->addChild(menuSelectFlight);
	

	FlightNumber = 0;
	LeiFlight0 = Sprite::create("img/Lei/0.png");

	LeiFlight1 = Sprite::create("img/Lei/1.png");
	LeiFlight1->setPosition(Point(-500,400));
	LeiFlight2= Sprite::create("img/Lei/2.png");
	LeiFlight2->setPosition(Point(-500,400));
	
	LeiFlight0->setScale(0.01f,0.01f);
	LeiFlight0->setPosition(Point(280,520));


	LeiFlight0->runAction(MoveTo::create(0.5f,Point(450,400)));
	LeiFlight0->runAction(ScaleTo::create(0.5f,1.0f,1.0f));
	
	this->addChild(LeiFlight0);
	this->addChild(LeiFlight1);
	this->addChild(LeiFlight2);
	LeiHelp = Sprite::create("img/Lei/help.png");
	
	LeiHelp->setPosition(450,1050);
	LeiHelp->setScale(0.8f,0.8f);



	LeiShop= Sprite::create("img/Lei/shop.png");
	LeiShop->setPosition(450,1050);
	LeiShop->setScale(0.8f,0.8f);


	LeiAboutUs= Sprite::create("img/Lei/about_us.png");
		LeiAboutUs->setPosition(450,1050);
		LeiAboutUs->setScale(0.7f,0.7f);


	this->addChild(LeiHelp);
	this->addChild(LeiShop);
	this->addChild(LeiAboutUs);

	return true;
}
Esempio n. 7
0
void UI::createLevelEditorUI()
{
	Size visibleSize = Director::getInstance()->getVisibleSize();
	auto labelMenuTitle = LabelTTF::create("Level Editor", "Segoe UI", 12);
	labelMenuTitle->setPosition(35.0f, visibleSize.height - 40.0f);
	m_pLevelEditor->addChild(labelMenuTitle);

	MenuItemImage* sidebarBackground = MenuItemImage::create("Resources/pictures/generic/ui_background.png", "ui_background.png", CC_CALLBACK_0(UI::nullCallback, this));
	sidebarBackground->setPosition(100.0f, visibleSize.height * 0.5f);
	sidebarBackground->setScale(200, visibleSize.height);

	MenuItemFont* addTextureObject = MenuItemFont::create("add texture", CC_CALLBACK_1(LevelEditor::addTextureObjectCallback, pLevelEditor));
	addTextureObject->setFontNameObj("Arial");
	addTextureObject->setFontSizeObj(30);
	addTextureObject->setPosition(80.0f, visibleSize.height - 80.0f);

	MenuItemFont* addGroundObject = MenuItemFont::create("add ground", CC_CALLBACK_1(LevelEditor::addGroundObjectCallback, pLevelEditor));
	addGroundObject->setFontNameObj("Arial");
	addGroundObject->setFontSizeObj(30);
	addGroundObject->setPosition(80.0f, visibleSize.height - 120.0f);

	MenuItemFont* addNutObject = MenuItemFont::create("add nut", CC_CALLBACK_1(LevelEditor::addNutObjectCallback, pLevelEditor));
	addNutObject->setFontNameObj("Arial");
	addNutObject->setFontSizeObj(30);
	addNutObject->setPosition(80.0f, visibleSize.height - 160.0f);

	MenuItemFont* addCrystalObject = MenuItemFont::create("add crystal", CC_CALLBACK_1(LevelEditor::addCrystalObjectCallback, pLevelEditor));
	addCrystalObject->setFontNameObj("Arial");
	addCrystalObject->setFontSizeObj(30);
	addCrystalObject->setPosition(80.0f, visibleSize.height - 200.0f);

	MenuItemFont* addAirObject = MenuItemFont::create("add aircurrent", CC_CALLBACK_1(LevelEditor::addAirObjectCallback, pLevelEditor));
	addAirObject->setFontNameObj("Arial");
	addAirObject->setFontSizeObj(30);
	addAirObject->setPosition(80.0f, visibleSize.height - 240.0f);

	MenuItemFont* changeLayerObject = MenuItemFont::create("mainLayer", CC_CALLBACK_0(LevelEditor::changeLayerCallback, pLevelEditor));
	changeLayerObject->setFontNameObj("Arial");
	changeLayerObject->setFontSizeObj(30);
	changeLayerObject->setPosition(73.0f, visibleSize.height - 280.0f);
	changeLayerObject->setTag(111);

	MenuItemFont* toggleGrid = MenuItemFont::create("snap to grid", CC_CALLBACK_0(LevelEditor::toggleGridCallback, pLevelEditor));
	toggleGrid->setFontNameObj("Arial");
	toggleGrid->setFontSizeObj(30);
	toggleGrid->setPosition(80.0f, visibleSize.height - 320.0f);
	toggleGrid->setTag(112);

	MenuItemFont* toggleSelectionMode = MenuItemFont::create("selection", CC_CALLBACK_0(LevelEditor::toggleSelectionMode, pLevelEditor));
	toggleSelectionMode->setFontNameObj("Arial");
	toggleSelectionMode->setFontSizeObj(30);
	toggleSelectionMode->setPosition(80.0f, visibleSize.height - 360.0f);
	toggleSelectionMode->setTag(113);

	MenuItemFont* saveLevelObject = MenuItemFont::create("save level", CC_CALLBACK_0(LevelEditor::saveLevelCallback, pLevelEditor));
	saveLevelObject->setFontNameObj("Arial");
	saveLevelObject->setFontSizeObj(30);
	saveLevelObject->setPosition(70.0f, visibleSize.height - 400.0f);

	MenuItemFont* mainMenuObject = MenuItemFont::create("Mainmenu", CC_CALLBACK_0(LevelEditor::mainMenuCallback, pLevelEditor));
	mainMenuObject->setFontNameObj("Arial");
	mainMenuObject->setFontSizeObj(30);
	mainMenuObject->setPosition(70.0f, visibleSize.height - 440.0f);

	auto menu = Menu::create(addTextureObject, addGroundObject, addNutObject, addCrystalObject, addAirObject, changeLayerObject, toggleSelectionMode, saveLevelObject, toggleGrid, mainMenuObject, NULL);
	auto menuBackground = Menu::create(sidebarBackground, NULL);
	menuBackground->setPosition(0, 0);
	menu->setPosition(0, 0);
	m_pLevelEditor->addChild(menu);
	m_pLevelEditor->addChild(menuBackground, -10);
	pLevelEditor->MainMenu = menu;
}
Esempio n. 8
0
//ʵ��HelpLayer���е�init��������ʼ������
bool HelpLayer::init()
{
    //���ø���ij�ʼ��
    if ( !Layer::init() )
    {
        return false;
    }

    //��ȡ�ɼ�����ߴ�
    Size visibleSize = Director::sharedDirector()->getVisibleSize();
    //��ȡ�ɼ�����ԭ������
    Point origin = Director::sharedDirector()->getVisibleOrigin();

	//������Ч
	CocosDenshion::SimpleAudioEngine::getInstance()->preloadEffect
	(
		"sf_button_press.mp3"
	);

    //����һ��������󣬰�������ͼ�
    Sprite* backSprite = Sprite::create("backgroundh.png");
    //���þ�������λ��
    backSprite->setPosition(Point(400,240));
	//��������ӵ�������
	this->addChild(backSprite,BACKGROUND_LEVEL_CGQ);

	//��������һ������ͼƬ������
	MenuItemImage *leftItem = MenuItemImage::create
	(
		"left_up.png",
		"left_down.png",
		CC_CALLBACK_1(HelpLayer::menuCallBack0, this)
	);
	leftItem->setScale(1.5);
	//���þ���˵���ť��λ��
	leftItem->setPosition(Point(330,450));

	//��������һ������ͼƬ������
	MenuItemImage *rightItem = MenuItemImage::create
	(
		"right_up.png",
		"right_down.png",
		CC_CALLBACK_1(HelpLayer::menuCallBack1, this)
	);
	rightItem->setScale(1.5);
	//���þ���˵���ť��λ��.
	rightItem->setPosition(Point(330,30));

	//���������ء�����
	MenuItemImage *fanhuiItem = MenuItemImage::create
	(
		"fanhui.png",
		"fanhui.png",
		CC_CALLBACK_1(HelpLayer::menuCallBack2, this)
	);
	//���þ���˵���ť��λ��.
	fanhuiItem->setPosition(Point(40,420));

	pMenu = Menu::create(leftItem,rightItem,fanhuiItem,NULL);
	//���ò˵���λ��
	pMenu->setPosition(Point(0,0));
	//���˵���ӵ�������
	this->addChild(pMenu,GAME_LEVEL_CGQ);
	initIntroPic();
    return true;
}
Esempio n. 9
0
// on "init" you need to initialize your instance
bool ReadyScene::init()
{
	//////////////////////////////
	// 1. super init first
	if (!Layer::init())
	{
		return false;
	}

	Singleton<WeaponDB>::getInstance();

	SpriteFrameCache::getInstance()->addSpriteFramesWithFile("clotharmor.plist");
	SpriteFrameCache::getInstance()->addSpriteFramesWithFile("thunder.plist");
	SpriteFrameCache::getInstance()->addSpriteFramesWithFile("ogre.plist");
	SpriteFrameCache::getInstance()->addSpriteFramesWithFile("pikachu.plist");
	SpriteFrameCache::getInstance()->addSpriteFramesWithFile("thunder_effect.plist");

	Size visibleSize = Director::getInstance()->getVisibleSize();
	Vec2 origin = Director::getInstance()->getVisibleOrigin();

	s = nullptr;

	auto backgroundSprite = Sprite::create("start_background.png");
	backgroundSprite->setPosition(Point(visibleSize.width / 2 + origin.x, visibleSize.height / 2 + origin.y));
	backgroundSprite->setScale(3);
	this->addChild(backgroundSprite);


	auto tmap = TMXTiledMap::create("StartMap.tmx");

	gamemap = new GameMap(tmap);

	player = new Player(this, gamemap);

	player->getSpriteObject()->setScale(1.5f);
	player->getSprite()->setPosition(Point(visibleSize.width * 7 / 24, visibleSize.height /2));

	s = new Weapon(1);
	player->setWeapon(s);

	MenuItemImage* PlayMenu = MenuItemImage::create("play_button1.png", "play_button2.png", CC_CALLBACK_1(ReadyScene::onMenu, this));
	PlayMenu->setScale(2.5f);

	Menu* menu = Menu::create(PlayMenu, NULL);
	menu->setPosition(visibleSize.width * 0.3f, visibleSize.height * 0.3f);
	this->addChild(menu, 1);

	MenuItemImage* LeftButton = MenuItemImage::create("left_button1.png", "left_button2.png", CC_CALLBACK_1(ReadyScene::onLeftButton, this));
	LeftButton->setScale(2.5f);

	Menu* left_bt = Menu::create(LeftButton, NULL);
	left_bt->setPosition(Point(visibleSize.width / 6, visibleSize.height / 2));
	this->addChild(left_bt, 1);

	MenuItemImage* RightButton = MenuItemImage::create("right_button1.png", "right_button2.png", CC_CALLBACK_1(ReadyScene::onRightButton, this));
	RightButton->setScale(2.5f);

	Menu* right_bt = Menu::create(RightButton, NULL);
	right_bt->setPosition(Point(visibleSize.width * 3 / 7, visibleSize.height   / 2));
	this->addChild(right_bt, 1);


	auto weapon_sprite = Sprite::create("weapon_font.png");
	weapon_sprite->setScale(2.0f);
	weapon_sprite->setPosition(Point(visibleSize.width * 0.55f, visibleSize.height * 0.75f));
	this->addChild(weapon_sprite);

	auto scrollView = ScrollView::create(Size(Singleton<WeaponDB>::getInstance()->getWeaponDBSize() * 48, 48));
	scrollView->setDirection(ScrollView::Direction::HORIZONTAL);
	scrollView->setContentOffset(Vec2(0, 0));
	scrollView->setContentOffsetInDuration(Vec2(0, 0), 10.f);
	scrollView->setPosition(Point(visibleSize.width * 0.5f, visibleSize.height * 0.6f));
	this->addChild(scrollView);

	
	MenuItemImage *test;
	Menu *menutest;

	for (int i = 1; i <= Singleton<WeaponDB>::getInstance()->getWeaponDBSize(); i++)
	{
		std::string str = StringUtils::format("%s_menu.png", Singleton<WeaponDB>::getInstance()->getWeaponData(i).path.c_str());

		test = MenuItemImage::create(str, str, CC_CALLBACK_1(ReadyScene::test2, this));
		test->setScale(2.5f);
		test->setTag(i);

		menutest = ScrollMenu::create(test, NULL);
		menutest->setPosition(Point((48 * i), 20));
		scrollView->addChild(menutest);
	}

	this->schedule(schedule_selector(ReadyScene::gameLogic), 0.2);

	return true;

}