void THIS::setBarRefreshV() { CCScrollView* sv = scrollView; CCSize viewSize = sv->getViewSize(); float total = sv->getContainer()->getContentSize().height - viewSize.height; float scrollBarSize = viewSize.height * viewSize.height / total; if(dynamicScrollSize) barV->setContentSize(CCSizeMake(barV->getContentSize().width, scrollBarSize)); else barV->setContentSize(barV->getOriginalSize()); CCSize barContentSize = barV->getContentSize();//, at); float offset = -sv->getContentOffset().y; float offsetX = -sv->getContentOffset().x; float percent = offset / total; percent = MIN(1, percent); percent = MAX(0, percent); percent = percent * (viewSize.height - barContentSize.height) / viewSize.height; float position = ((percent * viewSize.height) + barContentSize.height / 2.f); barV->setPosition(ccp(offsetX + viewSize.width, offset + position)); }
void THIS::setBarRefreshH() { CCScrollView* sv = scrollView; CCSize viewSize = sv->getViewSize(); float total = sv->getContainer()->getContentSize().width - viewSize.width; float scrollBarSize = viewSize.width * viewSize.width / total; if(dynamicScrollSize) barH->setContentSize(CCSizeMake(scrollBarSize, barH->getContentSize().height)); else barH->setContentSize(barH->getOriginalSize()); CCSize barContentSize = barH->getContentSize();//, at); float offset = -sv->getContentOffset().x; float offsetY = -sv->getContentOffset().y; float percent = offset / total; percent = MIN(1, percent); percent = MAX(0, percent); percent = percent * (viewSize.width - barContentSize.width) / viewSize.width; float position = (percent * viewSize.width) + barContentSize.width / 2.f; barH->setPosition(ccp(offset + position, offsetY)); }
CCRect VirtualizingPanel::getViewportRect() { CCPoint origin = this->convertToNodeSpace(CCPointZero); CCSize size = CCDirector::sharedDirector()->getWinSize(); CCScrollView* scroll = dynamic_cast<CCScrollView*>(this->getParent()); if (scroll != NULL) { origin = scroll->getContentOffset() * -1; size = scroll->getViewSize(); } return CCRect(origin.x, origin.y, size.width, size.height); }
void CJSScrollViewLayer::ccTouchEnded(CCTouch* touch, CCEvent* event) { CCPoint ptTouch = touch->getLocationInView(); ptTouch = CCDirector::sharedDirector()->convertToGL(ptTouch); CCLog("CJSScrollViewLayer::ccTouchEnded() x:%f , y:%f",ptTouch.x,ptTouch.y); CCPoint ptDif = ccpSub(ptTouch, mPtTouchBegan); if ( abs(ptDif.x) < 10) { CCScrollView *sv = (CCScrollView *)getChildByTag(TAG_JSSEL_SCROLLVIEW); CCRect rcScrollView = sv->boundingBox(); CCPoint ptOffset = sv->getContentOffset(); for (unsigned int i=0 ; i<m_arrThumb.count(); i++) { int nTag = TAG_JSSEL_SCROLLVIEW_SPRITE+i; CCSprite *sprite = (CCSprite *) m_arrThumb.objectAtIndex(i); CCRect rcSprite = sprite->boundingBox(); CCRect rcTouch = rcSprite; rcTouch.origin.x += ptOffset.x + rcScrollView.origin.x; rcTouch.origin.y = rcScrollView.origin.y; if (true == rcTouch.containsPoint(ptTouch)) { //CCScene *pScene = CCScene::create(); // sound 중지 if ( CocosDenshion::SimpleAudioEngine::sharedEngine()->isBackgroundMusicPlaying() ) CocosDenshion::SimpleAudioEngine::sharedEngine()->stopBackgroundMusic(); CocosDenshion::SimpleAudioEngine::sharedEngine()->stopAllEffects(); //CCLog(">>>>>>>>>>>>>>>>> scrollview tag : %d",nTag-TAG_EBOOK_SCROLLVIEW_SPRITE+1); /* CEbookLayer *layer = new CEbookLayer(nTag-TAG_JSSEL_SCROLLVIEW_SPRITE); // 이미지 인덱스 if (pScene && layer) { layer->autorelease(); pScene->addChild(layer); CCDirector::sharedDirector()->replaceScene(pScene); } */ SELECT_GAME game; game.nLevel = m_nGameLevel; game.nImgIndex = nTag-TAG_JSSEL_SCROLLVIEW_SPRITE; CCUserDefault::sharedUserDefault()->setIntegerForKey("JS_GAME_LEVEL", m_nGameLevel); /* // 마지막 촬영 이미지 선택 시 Jni로 Android 카메라 앱 불러 촬영 후 이미지 획득 후 게임 실행 if ( 12 == game.nImgIndex ) { #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) m_strImgPath = (char*)getImagePathToPlatform(); CCLog ("CJSScrollViewLayer m_strImgPath = %s", m_strImgPath); #else break; #endif } else { pScene = JS_Main::scene(game); CCDirector::sharedDirector()->replaceScene(CCTransitionFade::create( 0.3f, pScene ) ); } */ break; } } } }