1

私は Android ゲーム アプリケーションに取り組んでおり、cclayer を水平方向にスクロールする必要があります。メイン アクティビティがあり、メイン アクティビティに複数のレイヤーが追加されています。cclayer android cocos2dx で CCScroller または scrollview を使用する方法がわかりません

4

2 に答える 2

0

次のようなスクロールビューを作成できます。

CCScrollView *scrollView = CCScrollView::create(CCSizeMake(200, 120));
scrollView->setContentSize(CCSizeMake(400, 120));
scrollView->setPosition(CCPointZero);
scrollView->setDirection(kCCScrollViewDirectionHorizontal);
this->addChild(scrollView);

次に、次のようにサブレイヤーを追加できます。

CCLayerColor *layerColor = CCLayerColor::create(ccc4(255, 0, 0, 155), 200, 120);
layerColor->setPosition(ccp(0,0));
scrollView->addChild(layerColor);

CCLayer *layerColor = CCLayerColor::create(ccc4(0, 255, 0, 155), 200, 120);
layerColor->setPosition(ccp(200,0));
scrollView->addChild(layerColor);

お役に立てれば!

于 2013-10-05T22:21:59.643 に答える