Exemple #1
0
bool UI::initWithTag(int tag){
    if (!cocos2d::Scene::init()) {
        return false;
    }
    switch (tag) {
        case 1:
            initScale9Sprite();
            break;
            
        case 2:
            initListView();
            break;
            
        case 3:
            initLoadingBar();
            break;
            
        case 4:
            initPageView();
            break;
            
        case 5:
            initSliderView();
            break;
            
        case 6:
            initButton();
            break;
            
        case 7:
            initCheckBox();
            break;
            
        case 8:
            initImageView();
            break;
            
        case 9:
            initEditBox();
            break;
            
        case 10:
            initSrollView();
            break;
            
        case 11:
            initLayout();
            break;
        
            
        default:
            break;
    }
    
    
    
    
    return true;
}
Exemple #2
0
bool MainScene::init(CCScene* pScene)
{
    iBGIndex = 1;
    m_scene = pScene;
    
    if (CCLayer::init())
    {      
        m_rootNode = (NodeReader::getInstance()->createNode("R/MainScene_1.json"));
        addChild(m_rootNode);
        
        Layout *root = static_cast<Layout*>(m_rootNode->getChildren()->objectAtIndex(0));
        m_root = root;
        
        btnImport = initButton(BUTTON_IMPORT, root, this, toucheventselector(MainScene::touchEvent));
		btnImport->setTitleText(xStr("start"));
        initButton(BUTTON_PRV, root, this, toucheventselector(MainScene::touchEvent));
        initButton(BUTTON_NEXT, root, this, toucheventselector(MainScene::touchEvent));
        initButton(BUTTON_PREVIEW, root, this, toucheventselector(MainScene::touchEvent));
        initButton(BUTTON_REMOVE, root, this, toucheventselector(MainScene::touchEvent));
        initButton(BUTTON_CLEAN, root, this, toucheventselector(MainScene::touchEvent));
        initButton(BUTTON_SAVE, root, this, toucheventselector(MainScene::touchEvent));
        initButton(BUTTON_PREVIEW_ALL, root, this, toucheventselector(MainScene::touchEvent));
        initButton(CHANGE_BG, root, this, toucheventselector(MainScene::touchEvent));
        initButton(MOTION_PREVIEW, root, this, toucheventselector(MainScene::touchEvent));
        Button * btn = initButton(APPLY_TO_ALL, root, this, toucheventselector(MainScene::touchEvent));
        btn->setScale(0.5f);

        btn2x = initButton(BUTTON_2X, root, this, toucheventselector(MainScene::touchEvent));
        btn2x->setScale(0.3f, 0.5f);
        btnAddMotion = initButton(BUTTON_ADD_MOTION, root, this, toucheventselector(MainScene::touchEvent));
        btnAddMotion->setEnabled(false);
        btnDelMotion = initButton(BUTTON_DEL_MOTION, root, this, toucheventselector(MainScene::touchEvent));
        
        btnPre5 = initButton(BUTTON_PRV_5, root, this, toucheventselector(MainScene::touchEvent));
        btnNext5 = initButton(BUTTON_NEXT_5, root, this, toucheventselector(MainScene::touchEvent));
        
        //输入区
        m_ebAnchor[0] = InputBox::create(ANCHOR_X, root, this, m_rootNode);
        m_ebAnchor[1] = InputBox::create(ANCHOR_Y, root, this, m_rootNode);
        m_ebPosition[0] = InputBox::create(POSITION_X, root, this, m_rootNode);
        m_ebPosition[1] = InputBox::create(POSITION_Y, root, this, m_rootNode);
        m_ebRotate = InputBox::create(ROTATE, root, this, m_rootNode);
        m_ebScale = InputBox::create(SCALE, root, this, m_rootNode);
        m_ebDelay = InputBox::create(DELAY, root, this, m_rootNode);
        m_ebName = InputBox::create(SKILL_PART_NAME, root, this, m_rootNode);
        m_ebDegree = InputBox::create(DEGREE, root, this, m_rootNode);
        m_ebSpeed = InputBox::create(SPEED, root, this, m_rootNode);
        m_ebAttackDuration = InputBox::create(ATTACK_DURATION, root, this, m_rootNode);
        m_ebAttackInterval = InputBox::create(ATTACK_INTERVAL, root, this, m_rootNode);
        m_ebBulletType = InputBox::create(BULLET_TYPE, root, this, m_rootNode);
        m_ebBulletType->setText("0");

        m_pHolder = static_cast<CCSprite*>(m_rootNode->getChildByTag(SPRITE_HOLDER));
        m_pHolder->initWithFile("R/cross.png");
        m_iFrameBG = (ImageView*)UIHelper::seekWidgetByTag(root, FRAME_BG);
        m_iFrameBG->addTouchEventListener(this, toucheventselector(MainScene::touchEvent));

        m_iPreviewBG = (ImageView*)UIHelper::seekWidgetByTag(root, PREVIEW_BG);
        m_iPreviewBG->loadTexture("R/bg_1.jpg");
        m_iPreviewBG->setPosition(ccp(m_iPreviewBG->getPositionX() - 240, m_iPreviewBG->getPositionY()));
        m_iPreviewBG1 = ImageView::create();
        m_iPreviewBG1->loadTexture("R/bg_1.jpg");
        m_iPreviewBG1->setPosition(ccp(1440, 0));
        m_iPreviewBG->addChild(m_iPreviewBG1);
        
        m_lFrameCount = (Label*)UIHelper::seekWidgetByTag(root, LABEL_FRAME_COUNT);
        m_preview = static_cast<CCSprite*>(m_rootNode->getChildByTag(PREVIEW));
        m_preview->initWithFile("R/cross.png");
        m_preview->setVisible(false);
        
        xSkill->init(m_pHolder->getPosition(), m_preview->getPosition(), m_rootNode);
        
        //checkbox
        m_cbFlags[0] = initCheckBox(177, root, this, checkboxselectedeventselector(MainScene::selectedStateEvent));
        m_cbFlags[1] = initCheckBox(179, root, this, checkboxselectedeventselector(MainScene::selectedStateEvent));
        m_cbFlags[2] = initCheckBox(183, root, this, checkboxselectedeventselector(MainScene::selectedStateEvent));
        m_cbFlags[3] = initCheckBox(185, root, this, checkboxselectedeventselector(MainScene::selectedStateEvent));
        m_cbFlags[4] = initCheckBox(187, root, this, checkboxselectedeventselector(MainScene::selectedStateEvent));
        m_cbFlags[5] = initCheckBox(ISOLATE, root, this, checkboxselectedeventselector(MainScene::selectedStateEvent));
        m_cbFlags[6] = NULL;    //FI_BULLET_TYPE
        m_cbFlags[7] = initCheckBox(HIGH_LIGHT, root, this, checkboxselectedeventselector(MainScene::selectedStateEvent));

        m_cbNormal = initCheckBox(NORMAL_ATTACK, root, this, checkboxselectedeventselector(MainScene::selectedNormal));
        CCUserDefault::sharedUserDefault()->setBoolForKey(NORMAL, false);
        
        m_cbAttack = initCheckBox(ATTACK_FRAME, root, this, checkboxselectedeventselector(MainScene::selectedAttackFrame));
        
        m_lError = (Label*)(UIHelper::seekWidgetByTag(root, LABEL_ERROR));
        m_lError->setVisible(false);
        
        //列表
        listView = (UIListView*)UIHelper::seekWidgetByTag(root, PARTS_LIST);
        CCNode *node = (NodeReader::getInstance()->createNode("R/FolderBrowser_2.ExportJson"));
        listroot = static_cast<Layout*>(node->getChildren()->objectAtIndex(0));
        Layout* defaultItem = (Layout*)UIHelper::seekWidgetByTag(listroot, 32);         //还有转一层, 一来至少加2个Panel
        listView->setItemModel(defaultItem);
        
        _listAudio = (UIListView*)UIHelper::seekWidgetByTag(root, T_LIST_AUDIO);
        _listAudio->setItemModel(defaultItem);
        initButton(T_AUDIO_BACK, root, this, toucheventselector(MainScene::touchEvent));
        
        motionlist = (UIListView*)UIHelper::seekWidgetByTag(root, MOTION_LIST);
        motionlist->setItemModel(defaultItem);
        
        _layoutAudio = (Layout*)UIHelper::seekWidgetByTag(root, T_SELECT_AUDIO);
        _layoutAudio->setVisible(false);
        _btnAddAudio = initButton(T_ADD_AUDIO, root, this, toucheventselector(MainScene::touchEvent));
        
        xNotify->addObserver(this, callfuncO_selector(MainScene::updateProperty), UPDATE_PROPERTY, NULL);
        xNotify->addObserver(this, callfuncO_selector(MainScene::updateList), UPDATE_EFFECT_LIST, NULL);
        xNotify->addObserver(this, callfuncO_selector(MainScene::updateMotionList), UPDATE_MOTION_LIST, NULL);
        xNotify->addObserver(this, callfuncO_selector(MainScene::setFrameCount), UPDATE_ALL_INDEX, NULL);
        xNotify->addObserver(this, callfuncO_selector(MainScene::error), UPDATE_ERROR, NULL);
        
        setTouchEnabled(true);
        
        return true;
    }
    
    return true;
}