저는 Cocos2d-x에서 초보자입니다. 나는 ABCScene을 가지고 있는데, 다이얼 또는 플레이어에게 게임 레벨을 끝내기위한 다른 것을 표시하고 싶습니다. 또한 "Replay"+ "Next"버튼이 있습니다. 어떻게 할 수 있습니까?Cocos2d-x : 장면에서 대화 상자 만들기
어떤 아이디어라도 감사 할 것입니다. 모든 도움에 감사드립니다.
저는 Cocos2d-x에서 초보자입니다. 나는 ABCScene을 가지고 있는데, 다이얼 또는 플레이어에게 게임 레벨을 끝내기위한 다른 것을 표시하고 싶습니다. 또한 "Replay"+ "Next"버튼이 있습니다. 어떻게 할 수 있습니까?Cocos2d-x : 장면에서 대화 상자 만들기
어떤 아이디어라도 감사 할 것입니다. 모든 도움에 감사드립니다.
CCMenu를 사용할 수 있습니다.
당신은이 코드를 시도 할 수 있습니다:
{
CCSprite *gameOverBg = CCSprite::create("ui/scoreBoard.png");
gameOverBg->setPosition(ccp(winsize.width/2,winsize.height/2));
gameOverBg->setTag(1000);
this->addChild(gameOverBg);
CCSprite *menuItemBtn = CCSprite::create("ui/yesBtn1.png");
CCSprite *menuItemHvr = menuItemHvr->spriteWithFile("ui/yesBtn2.png");
CCMenuItemSprite *menuItem = CCMenuItemSprite::create(menuItemBtn, menuItemHvr, this, menu_selector(UIManager::menuCallbacks));
menuItem->setTag(1);
menuItem->setPosition(ccp(gameOverBg->getContentSize().width/2,gameOverBg->getContentSize().height/2-100));
CCLabelTTF *player = CCLabelTTF::create("User Player","Thonburi", 20);
player->setPosition(ccp(gameOverBg->getContentSize().width/2 - 100,gameOverBg->getContentSize().height/2+200));
player->setTag(2);
gameOverBg->addChild(player);
CCLabelTTF *ai = CCLabelTTF::create("AI Player", "Thonburi", 20);
ai->setPosition(ccp(gameOverBg->getContentSize().width/2 + 100,gameOverBg->getContentSize().height/2+200));
ai->setTag(3);
gameOverBg->addChild(ai);
CCLabelTTF *user = CCLabelTTF::create("000","Thonburi", 64);
user->setPosition(ccp(gameOverBg->getContentSize().width/2 - 100,gameOverBg->getContentSize().height/2+100));
user->setTag(2);
gameOverBg->addChild(user);
CCLabelTTF *opponent = CCLabelTTF::create("000", "Thonburi", 64);
opponent->setPosition(ccp(gameOverBg->getContentSize().width/2 + 100,gameOverBg->getContentSize().height/2+100));
opponent->setTag(3);
gameOverBg->addChild(opponent);
CCMenu *menuGameOver = CCMenu::create(menuItem,player,ai,user,opponent,NULL);
menuGameOver->setPosition(ccp(gameOverBg->getContentSize().width/2,gameOverBg->getContentSize().height * 0.35));
//menuGameOver->alignItemsHorizontallyWithPadding(8);
menuGameOver->setPosition(CCPointZero);
gameOverBg->addChild(menuGameOver);
}
CCDirector.sharedDirector().getActivity().runOnUiThread(new Runnable() {
public void run() {
AlertDialog.Builder builder = new AlertDialog.Builder(CCDirector.sharedDirector().getActivity());
builder.setMessage("Your Message here")
.setCancelable(false)
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
//your Code here
}
})
.setNegativeButton("No", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
AlertDialog alert = builder.create();
alert.show();
}
});
재미있는하지만 이사 ::의 getInstance를 (작동하지 않습니다) ->! '는 getActivity() 메소드를 가지고 있지 않으며'CCDirector'도 아니다. – John
확인이 질문에 http://stackoverflow.com/questions/7599285/cocos2d-how-to-create-a-popup-modal-dialog-을 with-cclayer – asloob