Cocos2d-x中CCScrollView的使用方法

CCScrollView的触摸优先级为0
	CCLayer *bg = CCLayer::create();
	bg->setContentSize(CCSizeMake(480*3,320*3));
	bg->setAnchorPoint(ccp(0,0));
	bg->setPosition(ccp(0,0));
	for(int i = 0; i <=2; i++){
		CCSprite *sprite= CCSprite::create("HelloWorld.png");
		sprite->setContentSize(ccp(480,320));
		sprite->setAnchorPoint(ccp(0, 0));
		sprite->setPosition(ccp(480*i,0));
		bg->addChild(sprite);
	}

	CCScrollView * view = CCScrollView::create(CCSizeMake(480,320),bg);
	view->setDirection(kCCScrollViewDirectionHorizontal);
	view->setAnchorPoint(ccp(0,0));
	view->setPosition(0,0);
	this->addChild(view);

相关推荐