Giter Club home page Giter Club logo

dxspinnerdemo's Introduction

DXSpinnerDemo

cocos2dx picker like ios UIPickerView

like iOS UIPickerView

Pure c++ code

//create pSpinner = nullptr;

setSpinner(DXSpinner::spinner());//create

pSpinner->setBackGroundColor(cocos2d::Color3B::BLUE);
pSpinner->setBackGroundColorType(cocos2d::ui::Layout::BackGroundColorType::SOLID);

pSpinner->setDelegate(this); //set delegate
pSpinner->setDataSource(this); //set datasource
pSpinner->setContentSize(cocos2d::Size(400, 200));//set size before  add to parent view

this->addChild(pSpinner); //add to view, will reload All Components

pSpinner->setPosition(cocos2d::Vec2(this->getContentSize().width/6,this->getContentSize().height/4));

pSpinner->selectRow(3, 1, true);//select row in Component

like ios UIPickerView 's Delegate //Delegate struct DXSpinnerDelegate : ProtocolBase { virtual const std::string titleForRowInComponent(DXSpinner *spinner, ssize_t row, ssize_t inComponent) = 0; //return title for row in component

virtual void didSelectRowInComponent(DXSpinner *spinner, ssize_t row, ssize_t inComponent) {}//callback when selected row changed 

};

like ios UIPickerView 's DataSource //DataSource struct DXSpinnerDataSource : ProtocolBase { virtual ssize_t numberOfComponents(DXSpinner *spinner) {return 1;};//Specifies the number of components virtual ssize_t numberOfRowsInComponent(DXSpinner *spinner, ssize_t inComponent) = 0;//Returns the number of rows for the specified component };

image

dxspinnerdemo's People

Contributors

doorxp avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.