CCScrollView 사용법

Cocos2Dx 2013. 8. 10. 17:25 |

 CCLayerColor *layer = CCLayerColor::create(ccc4(0,0,255,255));
 layer->setContentSize(CCSize(480,1000));


 CCScale9Sprite *spr = CCScale9Sprite::create("extensions/green_edit.png");
 spr->setContentSize(CCSize(400,50));
 spr->setPosition(ccp(240,900));
 layer->addChild(spr);

 CCScale9Sprite *spr2 = CCScale9Sprite::create("extensions/yellow_edit.png");
 spr2->setContentSize(CCSize(400,50));
 spr2->setPosition(ccp(240,100));
 layer->addChild(spr2);

 CCScrollView *scroll = CCScrollView::create(CCSize(480,320));
 scroll->setContainer(layer);
 scroll->setContentSize(layer->getContentSize());
 scroll->setAnchorPoint(CCPointZero);
 scroll->setPosition(ccp(0,0));
 scroll->setDirection(kCCScrollViewDirectionVertical);
 scroll->setContentOffset(ccp(0,-(1000-320))); // 시작위치 설정
 // kCCScrollViewDirectionBoth, kCCScrollViewDirectionHorizontal, kCCScrollViewDirectionVertical, kCCScrollViewDirectionNone

scroll->setContentOffsetInDuration(ccp(0,0), 5.0); // 자동 스크롤
 scroll->setBounceable(true);
 this->addChild(scroll);

Posted by maysent
: