Exemplo n.º 1
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;
}
// on "init" you need to initialize your instance
bool HelloWorld::init()
{
    //////////////////////////////
    // 1. super init first
    if ( !Layer::init() )
    {
        return false;
    }
    
    TableView *tv = TableView::create(this,Size(300,300));
    
    tv->setAnchorPoint(Point(0,0));
    tv->setPosition(100, 100);
    tv->setDelegate(this);
    addChild(tv);
    
    return true;
}