float CScrollMenu::getScrollPecent() { if (m_sRadioSize.width == _size.width) return 0.0f; Point pos = getInnerContainer()->getPosition(); float moveOffset = -pos.x; return moveOffset*100/(m_sRadioSize.width-_size.width); }
void EquipmentInfo::imageClick(Ref* pSender, TouchEventType type) { auto ptLoc = Point(0, 0); auto task = (Widget *)pSender; auto tag = task->getTag(); auto scroll = (cocos2d::ui::ScrollView *)task->getParent()->getParent()->getParent(); auto inner = scroll->getInnerContainer(); auto temp = scroll->getContentSize().height - inner->getContentSize().height; if ( isFull ) { for (unsigned int i = 0; i < tempEquipVector.size(); i++) { auto ttt = (EquipmentCell*)equipmentScrollView->getChildByTag( 100 + i ); auto equipBG = dynamic_cast<ImageView* >(ttt->equipmentPanel->getChildByName("Image_BG")); equipBG->loadTexture("TempPic/Selected.png"); equipBG->setScale( 1.3f ); equipBG->setVisible(false); } } else { for (unsigned int i = 0; i < tempEquipVector.size() - 1; i++) { auto ttt = (EquipmentCell*)equipmentScrollView->getChildByTag( 100 + i ); auto equipBG = dynamic_cast<ImageView* >(ttt->equipmentPanel->getChildByName("Image_BG")); equipBG->loadTexture("TempPic/Selected.png"); equipBG->setScale( 1.3f ); equipBG->setVisible(false); } } if (type == TOUCH_EVENT_ENDED) { ptLoc = task->getTouchEndPos(); if ( ( (ptLoc.x <= m_ptTouchLoc.x + 10) && ( ptLoc.y <= m_ptTouchLoc.y + 10 )) || ( (ptLoc.x >= m_ptTouchLoc.x - 10) && ( ptLoc.y >= m_ptTouchLoc.y - 10 ) ) ) { ToolFunc::playEffectFile( Click ); singleEquipmentInfo(tag, 0); auto equipBG = dynamic_cast<ImageView* >(Helper::seekWidgetByName(task, "Image_BG")); equipBG->setVisible(true); } } else if ( TOUCH_EVENT_BEGAN == type ) { m_ptTouchLoc = task->getTouchStartPos(); m_ptOriginleLoc = inner->getPosition(); } else if ( TOUCH_EVENT_MOVED == type ) { ptLoc = task->getTouchMovePos(); auto pt = m_ptOriginleLoc.y + ptLoc.y - m_ptTouchLoc.y; pt = (pt > 0) ? 0 : pt; pt = (pt < temp) ? temp : pt; inner->setPositionY(pt); } }
void UI:: ScrollView(Ref*s,cocos2d::ui::ScrollView::EventType ty){ auto scr=dynamic_cast<class ScrollView*>(s); if (ty==ScrollView::EventType::BOUNCE_BOTTOM) CCLOG("Bounce_BOtton"); else if (ty==cocos2d::ui::ScrollView::EventType::BOUNCE_LEFT) CCLOG("scroll_To_left"); else if(ty==cocos2d::ui::ScrollView::EventType::BOUNCE_RIGHT); CCLOG("Scroll_To_Right"); Point a=scr->getInnerContainer()->getPosition(); log("x=%f,y=%f",a.x,a.y); }
float CScrollMenu::getTurningWidthRight() { Point pos = getInnerContainer()->getPosition(); float leftWidth = -pos.x; if (leftWidth > _size.width) { return _size.width; } else { return leftWidth+m_fExtraTurn; } }
float CScrollMenu::getTurningWidthLeft() { Point pos = getInnerContainer()->getPosition(); float leftWidth =(m_sRadioSize.width - (-pos.x + _size.width)); if (leftWidth>_size.width) { return _size.width; } else { return leftWidth+m_fExtraTurn; } }