Esempio n. 1
0
// on "init" you need to initialize your instance
bool TableViewTest::init()
{
    if ( !TestCase::init() )
    {
        return false;
    }

	Size winSize = Director::getInstance()->getWinSize();

    TableView* tableView = TableView::create(this, Size(250, 60));
    tableView->setDirection(ScrollView::Direction::HORIZONTAL);
    tableView->setPosition(Vec2(20,winSize.height/2-30));
    tableView->setDelegate(this);
    this->addChild(tableView);
    tableView->reloadData();

	tableView = TableView::create(this, Size(60, 250));
	tableView->setDirection(ScrollView::Direction::VERTICAL);
	tableView->setPosition(Vec2(winSize.width-150,winSize.height/2-120));
	tableView->setDelegate(this);
	tableView->setVerticalFillOrder(TableView::VerticalFillOrder::TOP_DOWN);
	this->addChild(tableView);
	tableView->reloadData();

    return true;
}
Esempio n. 2
0
// on "init" you need to initialize your instance
bool TableViewTestLayer::init()
{
    if ( !Layer::init() )
    {
        return false;
    }

	Size winSize = Director::getInstance()->getWinSize();

    TableView* tableView = TableView::create(this, Size(250, 60));
    tableView->setDirection(ScrollView::Direction::HORIZONTAL);
    tableView->setPosition(Point(20,winSize.height/2-30));
    tableView->setDelegate(this);
    this->addChild(tableView);
    tableView->reloadData();

	tableView = TableView::create(this, Size(60, 250));
	tableView->setDirection(ScrollView::Direction::VERTICAL);
	tableView->setPosition(Point(winSize.width-150,winSize.height/2-120));
	tableView->setDelegate(this);
	tableView->setVerticalFillOrder(TableView::VerticalFillOrder::TOP_DOWN);
	this->addChild(tableView);
	tableView->reloadData();

	// Back Menu
	MenuItemFont *itemBack = MenuItemFont::create("Back", CC_CALLBACK_1(TableViewTestLayer::toExtensionsMainLayer, this));
	itemBack->setPosition(Point(VisibleRect::rightBottom().x - 50, VisibleRect::rightBottom().y + 25));
	Menu *menuBack = Menu::create(itemBack, NULL);
	menuBack->setPosition(Point::ZERO);
	addChild(menuBack);

    return true;
}
// on "init" you need to initialize your instance
bool TableViewTestLayer::init()
{
    if ( !Layer::init() )
    {
        return false;
    }

	Size winSize = Director::sharedDirector()->getWinSize();

    TableView* tableView = TableView::create(this, CCSizeMake(250, 60));
    tableView->setDirection(kScrollViewDirectionHorizontal);
    tableView->setPosition(ccp(20,winSize.height/2-30));
    tableView->setDelegate(this);
    this->addChild(tableView);
    tableView->reloadData();

	tableView = TableView::create(this, CCSizeMake(60, 250));
	tableView->setDirection(kScrollViewDirectionVertical);
	tableView->setPosition(ccp(winSize.width-150,winSize.height/2-120));
	tableView->setDelegate(this);
	tableView->setVerticalFillOrder(kTableViewFillTopDown);
	this->addChild(tableView);
	tableView->reloadData();

	// Back Menu
	MenuItemFont *itemBack = MenuItemFont::create("Back", CC_CALLBACK_1(TableViewTestLayer::toExtensionsMainLayer, this));
	itemBack->setPosition(ccp(VisibleRect::rightBottom().x - 50, VisibleRect::rightBottom().y + 25));
	Menu *menuBack = Menu::create(itemBack, NULL);
	menuBack->setPosition(PointZero);
	addChild(menuBack);

    return true;
}
Esempio n. 4
0
// on "init" you need to initialize your instance
bool Overview::init()
{
    //初期化
    if ( !Layer::init() ) return false;
    
    //userDefaultの読み込み
    userDefault = UserDefault::getInstance();
    
    //ストーリー
    storyManager = StoryManager::getInstance();
    
    //話数
    story_count = storyManager->getStoryCount();
    
    //リスト
    story_list = storyManager->gets();
    
    //画面サイズサイズを取得
    window_size = Director::getInstance()->getWinSize();
    
    TableView* tableView = TableView::create(this, Size(window_size.width / 100 * 80, window_size.height / 100 * 80));
    //展開方向
    tableView->setDirection(TableView::Direction::VERTICAL);
    //表示順序上からしたへ
    tableView->setVerticalFillOrder(TableView::VerticalFillOrder::TOP_DOWN);
    tableView->setPosition(Point((window_size.width - tableView->getContentSize().width) / 2, 20));
    tableView->setBounceable(false);
    //追加
    tableView->setDelegate(this);
    addChild(tableView);
    tableView->reloadData();
    return true;
}
Esempio n. 5
0
// on "init" you need to initialize your instance
bool MainScene::init()
{
    //////////////////////////////
    // 1. super init first
    if ( !Layer::init() )
    {
        return false;
    }

    initBackground();

    curEquipment = NULL;
	Size winSize = Director::getInstance()->getWinSize();
	Vec2 origin = Director::getInstance()->getVisibleOrigin();

	TableView* tableView = TableView::create(this, Size(winSize.width, 200));
	tableView->setDirection(ScrollView::Direction::HORIZONTAL);
	tableView->setAnchorPoint(Vec2::ANCHOR_MIDDLE);
	tableView->setPosition(Point(winSize.width*0.2 + origin.x, winSize.height/2 + origin.y - 50));
	tableView->setDelegate(this);
	this->addChild(tableView);
	tableView->reloadData();

	auto listener = EventListenerKeyboard::create();
	listener->onKeyReleased = CC_CALLBACK_2(MainScene::onKeyReleased,this);
	Director::getInstance()->getEventDispatcher()->addEventListenerWithSceneGraphPriority(listener,this);

    return true;
}
Esempio n. 6
0
//显示选中的难度相对应的排名
void RankScene::showRank(Ref* pSender, Control::EventType controlEvent)
{

	SimpleAudioEngine::getInstance()->playEffect(music_click);

	int news = 3001;
	ControlButton* bt;
	for (int i = 3001; i <= 3003; i++)
	{
		bt = (ControlButton *)this->getChildByTag(i);
		if (bt == pSender)
		{
			news = i;
			break;
		}
	}
	if (news == selected) return;

	//放大选择难度
	this->getChildByTag(selected)->setScale(1.0f);
	this->getChildByTag(news)->setScale(1.1f);
	selected = news;

	//选择难度
	if (selected == 3001)		opt = "easy"; //简单
	else if (selected == 3002)	opt = "normal"; //普通
	else if (selected == 3003)	opt = "hard"; //困难

	//获取排名 CCTbaleView , tag = 3005
	TableView *tb = (TableView *)this->getChildByTag(3005);
	tb->reloadData();
}
Esempio n. 7
0
bool SceneRule::init()
{
    if (!Layer::init()) {
        return false;
    }
    
    auto bg = KUtil::addSprite(this, KUtil::getPath(F_BG, "bg_3.png"), Point(HALF_WIDTH, 0), ANCHOR_CENTER_DOWN, 0);
    bg->setScale(KUtil::getScale(FULL_WIDTH, FULL_HEIGHT, bg->getContentSize(), true));
    
    Size size = Size(FULL_WIDTH-20, FULL_HEIGHT-160-10);
    auto tbg = GameTool::addTextBg(this, size, Point(10, 160), ANCHOR_LEFT_DOWN, 10);
    
    detailLabel = KUtil::addLabelConfig(tbg, DETAIL_POINT_MATCH, KUtil::getPath(F_FONT, "luoliti.ttf"), 30, Point(10, 10), Color4B(0, 0, 0, 255), ANCHOR_LEFT_DOWN, 10, Size(size.width-20, size.height-20), TextHAlignment::LEFT, TextVAlignment::TOP);
    
    Vector<MenuItem *> itemArray;
    
    GameTool::addBtn2(&itemArray, "返回", 32, Point(FULL_WIDTH-5, FULL_HEIGHT-5), ANCHOR_RIGHT_UP, CC_CALLBACK_1(SceneRule::callbackBack, this));
    
    KUtil::addMenu(this, &itemArray, 30);
    
    listQAKind.pushBack(QAKind::create(QAKIND_POINT_MATCH, "普通赛规则"));
    listQAKind.pushBack(QAKind::create(QAKIND_HUNDRED_MATCH, "冲百赛规则"));
    listQAKind.pushBack(QAKind::create(QAKIND_BIGTWO_RULE, "锄大地规则"));
    
    cellHeight = 160;
    cellWidth = 250;
    TableView* tableView = TableView::create(this, Size(FULL_WIDTH, cellHeight));
    tableView->setDirection(ScrollView::Direction::HORIZONTAL);
    tableView->setPosition(Point(0, 0));
    tableView->setDelegate(this);
    this->addChild(tableView, 100);
    tableView->reloadData();
    
    return true;
}
Esempio n. 8
0
bool TaskListLayer::init()
{
	if (!Layer::init())
	{
		return false;
	}

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

	TableView* tableView = TableView::create(this, Size(600, 500));
	tableView->setDirection(cocos2d::extension::ScrollView::Direction::VERTICAL); //方向垂直
	tableView->setPosition(Point::ZERO);
	tableView->setDelegate(this);
	tableView->setTag(0);
	addChild(tableView);

	tableView->setVerticalFillOrder(TableView::VerticalFillOrder::TOP_DOWN);  //填充次序从上到下
	tableView->reloadData();

	return true;
}
static int lua_cocos2dx_TableView_create(lua_State* L)
{
    if (nullptr == L)
        return 0;

    int argc = 0;
    bool ok = true;

#if COCOS2D_DEBUG >= 1
    tolua_Error tolua_err;
    if (!tolua_isusertable(L,1,"cc.TableView",0,&tolua_err)) goto tolua_lerror;
#endif

    argc = lua_gettop(L) - 1;

    if (2 == argc || 1 == argc)
    {
        LUA_TableViewDataSource* dataSource = new (std::nothrow) LUA_TableViewDataSource();
        Size size;
        ok &= luaval_to_size(L, 2, &size, "cc.TableView:create");

        TableView* ret = nullptr;

        if (1 == argc)
        {
            ret = TableView::create(dataSource, size);
        }
        else
        {
#if COCOS2D_DEBUG >= 1
            if (!tolua_isusertype(L,3,"cc.Node",0,&tolua_err)) goto tolua_lerror;
#endif
            Node* node = static_cast<Node*>(tolua_tousertype(L, 3, nullptr));
            ret = TableView::create(dataSource, size, node);
        }

        if (nullptr ==  ret)
            return 0;

        ret->reloadData();

        __Dictionary* userDict = new __Dictionary();
        userDict->setObject(dataSource, KEY_TABLEVIEW_DATA_SOURCE);
        ret->setUserObject(userDict);
        userDict->release();

        dataSource->release();


        int  nID = (int)ret->_ID;
        int* pLuaID =  &ret->_luaID;
        toluafix_pushusertype_ccobject(L, nID, pLuaID, (void*)ret,"cc.TableView");

        return 1;
    }
    luaL_error(L, "'create' function of TableView wrong number of arguments: %d, was expecting %d\n", argc, 1);
    return 0;

#if COCOS2D_DEBUG >= 1
tolua_lerror:
    tolua_error(L,"#ferror in function 'create'.",&tolua_err);
    return 0;
#endif
}
Esempio n. 10
0
// on "init" you need to initialize your instance
bool ArtScene::init()
{
	setTouchEnabled(false);
	CCLog("INIT!");
	//draw a giant box behind everything
	Size visibleSize = Director::getInstance()->getVisibleSize();
	Point origin = Director::getInstance()->getVisibleOrigin();
	_selectedIndex = 0;
	_selectedGallary = GameManager::getInstance()->getSelectedGallary();
	_selectedArt = ArtManager::getInstance()->getArt(_selectedGallary->artIds.at(_selectedIndex));

	auto background = LayerColor::create(Color4B::WHITE, visibleSize.width, visibleSize.height);
	background->setPosition(Point(0, 0));
	addChild(background);

	auto redBox = TopBar::create();
	addChild(redBox);

	auto blackBox = LayerColor::create(Color4B::BLACK, visibleSize.width, 40 * G_assetScale);
	blackBox->setPosition(Point(0, 0));
	addChild(blackBox);

	auto gradBox1 = LayerGradient::create(Color4B(120, 120, 120, 255), Color4B(243, 243, 243, 255), Point(1, 0));
	gradBox1->setContentSize(Size(visibleSize.width * 0.5f, 60 * G_assetScale));
	gradBox1->setPosition(Point(0, 40 * G_assetScale));
	addChild(gradBox1);

	auto gradBox2 = LayerGradient::create(Color4B(243, 243, 243, 255), Color4B(120, 120, 120, 255), Point(1, 0));
	gradBox2->setContentSize(Size(visibleSize.width * 0.5f, 60 * G_assetScale));
	gradBox2->setPosition(Point(visibleSize.width * 0.5f, 40 * G_assetScale));
	addChild(gradBox2);

	auto slimBar = LayerColor::create(Color4B(151, 151, 151, 255), visibleSize.width, 1);
	slimBar->setPosition(Point(0, 100 * G_assetScale));
	addChild(slimBar);

	auto slimBar2 = LayerColor::create(Color4B(51, 51, 51, 255), visibleSize.width, 1);
	slimBar2->setPosition(Point(0, visibleSize.height - redBox->getContentSize().height - 1));
	addChild(slimBar2);

	auto picBox = LayerColor::create(Color4B::BLACK, visibleSize.width - 50, 120 * G_assetScale);
	picBox->setPosition(Point(25, visibleSize.height - 240 * G_assetScale));
	addChild(picBox);

	auto artY = 180.0f * G_assetScale;
	_artImage = CCSprite::create();
	_artImage->setPosition(Point(visibleSize.width * 0.5f, visibleSize.height - artY));
	addChild(_artImage);

	float starBoxSize = 75 * G_assetScale;
	float starBoxPadding = 18 * G_assetScale;
	float starY = 128 * G_assetScale;
	float starX1 =(visibleSize.width - starBoxSize) * 0.5f;
	float starX2 = starX1 - (starBoxPadding + starBoxSize);
	float starX3 = starX1 + starBoxPadding + starBoxSize;
	
	_starBox1 = (DifficultyButton*)DifficultyButton::create();
	_starBox1->setPosition(starX2, starY);
	addChild(_starBox1);
	
	_starBox2 = (DifficultyButton*)DifficultyButton::create();
	_starBox2->setPosition(starX1, starY);
	addChild(_starBox2);

	_starBox3 = (DifficultyButton*)DifficultyButton::create();
	_starBox3->setPosition(starX3, starY);
	addChild(_starBox3);
	
	{
		FontDefinition fontDef;
		fontDef._fontName = Utils::getExtraBoldFont();
		fontDef._fontSize = round(12 * G_assetScale) * 4;

		auto label = LabelTTF::createWithFontDefinition("GALLARY " + _selectedGallary->romanNumber, fontDef);
		label->setPosition(visibleSize.width * 0.5f, visibleSize.height - 60 * G_assetScale);
		label->setColor(Color3B::BLACK);
		label->setScale(0.25f);
		addChild(label);
	}
	{
		FontDefinition fontDef;
		fontDef._fontName = Utils::getBoldItalicFont();
		fontDef._fontSize = round(24 * G_assetScale) * 4;
		
		auto label = LabelTTF::createWithFontDefinition(_selectedGallary->name, fontDef);
		label->setPosition(visibleSize.width * 0.5f, visibleSize.height - 79 * G_assetScale);
		label->setColor(Color3B::BLACK);
		label->setScale(0.25f);
		addChild(label);
	}
	{
		FontDefinition fontDef;
		fontDef._fontName = Utils::getBoldItalicFont();
		fontDef._fontSize = round(16 * G_assetScale) * 4;

		_artLabel = LabelTTF::createWithFontDefinition("", fontDef);
		_artLabel->setPosition(visibleSize.width * 0.5f, visibleSize.height - 265 * G_assetScale);
		_artLabel->setColor(Color3B::BLACK);
		_artLabel->setScale(0.25f);
		addChild(_artLabel);
	}
	{
		FontDefinition fontDef;
		fontDef._fontName = Utils::getBoldItalicFont();
		fontDef._fontSize = round(12 * G_assetScale) * 4;
		_artistLabel = LabelTTF::createWithFontDefinition("", fontDef);
		_artistLabel->setPosition(visibleSize.width * 0.5f, visibleSize.height - 285 * G_assetScale);
		_artistLabel->setColor(Color3B::BLACK);
		_artistLabel->setScale(0.25f);
		addChild(_artistLabel);
	}
	
	TableView* tableView = TableView::create(this, Size(Size(visibleSize.width, 60 * G_assetScale)));
	tableView->setDirection(ScrollView::Direction::HORIZONTAL);
	tableView->setPosition(Point(0, 40 * G_assetScale));
	tableView->setDelegate(this);
	this->addChild(tableView);
	tableView->reloadData();

	drawSelected();

    return true;
}