setScale9Enabled(true); custom_button->setSize(default_button->getSize());" name="description" />

cocos2d-x3.0 ListView(2)

来源:未知 责任编辑:责任编辑 发表时间:2014-05-26 10:56 点击:
& items = listView->getItems(); ssize_t items_count = items.size(); for (int i = 0; i < count / 4; ++i) { Button* custom_button = Button::create("button.png","buttonHighlighted.png"); custom_button->setName("Title Button"); custom_button->setScale9Enabled(true); custom_button->setSize(default_button->getSize()); Layout* custom_item = Layout::create(); custom_item->setSize(custom_button->getSize()); custom_button->setPosition(Point(custom_item->getSize().width / 2.0f, custom_item->getSize().height / 2.0f)); custom_item->addChild(custom_button); listView->insertCustomItem(custom_item, items_count); } //set item data items_count = items.size(); for (int i = 0; i < items_count; ++i) { Widget* item = listView->getItem(i); Button* button = static_cast(item->getChildByName("Title Button")); size_t index = listView->getIndex(item); button->setTitleText(static_cast(_array.at(index)).c_str()); } listView->removeLastItem(); // listView->removeAllItems(); listView->setGravity(LISTVIEW_GRAVITY_CENTER_VERTICAL); listView->setItemsMargin(15.0f);
void LayoutTest::selectedItemEvent(cocos2d::Ref *pSender, ListViewEventType type)
{
    
    switch (type) {
        case cocos2d::ui::LISTVIEW_ONSELECTEDITEM_START:
        {
            ListView* listView = static_cast(pSender);
            
            log("%ld",listView->getCurSelectedIndex());
        }
            break;
        
            
        case cocos2d::ui::LISTVIEW_ONSELECTEDITEM_END:
        {
            ListView* listView = static_cast(pSender);
            
            log("%ld",listView->getCurSelectedIndex());
        }
            break;
        default:
            break;
    }
}


发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
用户名: 验证码:点击我更换图片
最新评论 更多>>

推荐热点

  • cocos2d-x学习笔记(19)--label 、label atlas
  • cocos2d-x学习笔记(23)--地图的使用3--CCTMXLayer
  • Cocos2d-x学习(一):HelloWorld
  • cocos2dx在xcode下开发,编译到android上(2)
  • cocos2d 设置屏幕默认方向
  • Cocos2d-x 2.0 之 Actions “三板斧” 之一
  • cocos2d-x学习笔记(22)--地图的使用2(TMX) --Z-Order、AnchorPoi
  • cocos2d-x学习笔记(18)--游戏打包(windows平台)
  • cocos2d-x学习笔记(16)--spritesheet(精灵表单)
网站首页 - 友情链接 - 网站地图 - TAG标签 - RSS订阅 - 内容搜索
Copyright © 2008-2015 计算机技术学习交流网. 版权所有

豫ICP备11007008号-1