このコードを試してください -
CCMenu *myMenu = CCMenu::create();
myMenu->setPosition(CCPointZero);
this->addChild(myMenu);
int leftMargin = 20;
int topMargin = 500;
int index = 0;
for (int i=0; i<5; i++) {
leftMargin = 150;
if (i%2 != 0) {
leftMargin = leftMargin-(100/2);
}
for (int j=0; j<5; j++) {
CCMenuItemImage *hexImg = CCMenuItemImage::create("hexagon_new.png", "hexagon_new.png", this, menu_selector(Hexagon::clickOnHex));
hexImg->setRotation(90);
hexImg->setPosition(ccp(leftMargin, topMargin));
hexImg->setTag(index);
hexImg->setScale(115/hexImg->getContentSize().width);
myMenu->addChild(hexImg);
index++;
leftMargin += 100;
}
topMargin -= 82;
}
ユーザータッチで六角形のアニメーションを行う機能は -
void Hexagon::clickOnHex(CCObject *sender){
CCMenuItemImage *tempHex = (CCMenuItemImage *)sender;
CCRotateBy *rotateBy = CCRotateBy::create(0.5, 360);
tempHex->runAction(rotateBy);
CCLOG("HEX CLICKED");
}
やりたいことをアニメーションにします。
これは私が使用した画像です。
六角形の画像