void Popup::popupLayer(){ // 定义一个弹出层,传入一张背景图 PopupLayer* pl = PopupLayer::create("popuplayer/BackGround.png"); // ContentSize 是可选的设置,可以不设置,如果设置把它当作 9 图缩放 pl->setContentSize(CCSizeMake(400, 350)); pl->setTitle("Message Tile"); pl->setContentText("Text content test", 20, 60, 250); // 设置回调函数,回调传回一个 CCNode 以获取 tag 判断点击的按钮 // 这只是作为一种封装实现,如果使用 delegate 那就能够更灵活的控制参数了 pl->setCallbackFunc(this, callfuncN_selector(Popup::buttonCallback)); // 添加按钮,设置图片,文字,tag 信息 pl->addButton("popuplayer/pop_button.png", "popuplayer/pop_button.png", "YES", 0); pl->addButton("popuplayer/pop_button.png", "popuplayer/pop_button.png", "NO", 1); // 添加到当前层 this->addChild(pl); }
void HelloWorld::popupLayer(){ // 定义一个弹出层,传入一张背景图 PopupLayer* pl = PopupLayer::create("bg.png"); // ContentSize 是可选的设置,可以不设置,如果设置把它当作 9 图缩放 pl->setContentSize(CCSizeMake(400, 280)); // pl->setTitle("吾名一叶"); pl->setContentText("有招聘信息的HR可以联系管理员发群公告!望管理员也给予积极配合,谢谢!群号:389970612 C/C++/OC/C#/JAVA/PHP/SQL....", 12, 10, 250); pl->setColor(Color3B(250, 60, 60)); // 设置回调函数,回调传回一个 CCNode 以获取 tag 判断点击的按钮 // 这只是作为一种封装实现,如果使用 delegate 那就能够更灵活的控制参数了 pl->setCallbackFunc(this, callfuncN_selector(HelloWorld::buttonCallback)); // 添加按钮,设置图片,文字,tag 信息 pl->addButton("bt1.png", "bt2", "确定", 0); pl->addButton("bt1.png", "bt2.png", "取消", 1); // 添加到当前层 this->addChild(pl); }
void CollageScene::popupLayer(Node* baseLayer,Vec2 popPos,const char *sTitle,string sContent){ PopupLayer* pl = PopupLayer::create("popup_sq.png"); pl->setContentSize(Size(450, 250)); //auto sizeLayer = baseLayer->getContentSize(); pl->setAnchorPoint(Vec2(.5,.5)); pl->setPosition(popPos.x,popPos.y); pl->setTitle(sTitle,Color3B(106,72,36)); pl->setContentText(sContent.c_str(),Color3B(106,72,36), 24, 20, 150); pl->setCallbackFunc(this, callfuncND_selector(CollageScene::popupCallback),NULL); // 添加按钮,设置图片,文字,tag 信息 pl->addButton("button_normal.png", "button_dis.png", "RETURN",Color3B(255,255,255), 1); // 添加到指定层 baseLayer->addChild(pl); }
void HelloWorld::keyBackClicked() { #if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) CCMessageBox("You pressed the close button. Windows Store Apps do not implement a close button.","Alert"); #else PopupLayer* pl = PopupLayer::create("pop_bg.png"); // ContentSize 是可选的设置,可以不设置,如果设置把它当作 9 图缩放 pl->setContentSize(CCSizeMake(400, 300)); pl->setTitle("确认"); pl->setContentText("要离开游戏吗?", 28, 60, 250); // 设置回调函数,回调传回一个 CCNode 以获取 tag 判断点击的按钮 // 这只是作为一种封装实现,如果使用 delegate 那就能够更灵活的控制参数了 pl->setCallbackFunc(this, callfuncN_selector(HelloWorld::popupCallback)); // 添加按钮,设置图片,文字,tag 信息 pl->addButton("pop_button.png", "pop_button.png", "退出", 0); pl->addButton("pop_button.png", "pop_button.png", "取消", 1); // 添加到当前层 this->addChild(pl, 5); #endif }
bool T2::checkGameOver() { isRightOver = isLeftOver = false; isUpOver = isDownOver =false; over_check_move_right = over_check_heti_right =false; over_check_move_left = over_check_heti_left = false; over_check_move_up = over_check_heti_up= false; over_check_move_down = over_check_heti_down = false; //check right for (int i=0;i<MAX_ROW;i++) { for (int j = MAX_COL-2; j >=0 ; --j) { if(arr_Num[i][j]>-1&&arr_Num[i][j+1]==-1)//¬ª√ÅœÄÀö‚Äù‚Äú¬±Ô¨Ç¬†¬´√∏‚Äô¬µ∆? over_check_move_right = true; } } for (int i=0;i<MAX_ROW;i++) { for (int j=MAX_COL-1;j>0;j--) { if(arr_Num[i][j]>=0&&arr_Num[i][j]==arr_Num[i][j-1]) over_check_heti_right = true; } } if(!over_check_move_right&&!over_check_heti_right) { isRightOver = true; } //check -left for (int i=0;i<MAX_ROW;i++) { for (int j =1; j < MAX_COL ; j++) { if(arr_Num[i][j]>-1&&arr_Num[i][j-1]==-1)//¬ª√ÅœÄÀö‚Äù‚Äú¬±Ô¨Ç¬†¬´√∏‚Äô¬µ∆? over_check_move_left = true; } } for (int i=0;i<MAX_ROW;i++) { for (int j=0;j<MAX_COL-1;j++) { if(arr_Num[i][j]>=0&&arr_Num[i][j]==arr_Num[i][j+1]) over_check_heti_left = true; } } if(!over_check_move_left&&!over_check_heti_left) isLeftOver = true; //check -up for (int j =0; j < MAX_COL ; j++)//lie { for (int i= MAX_ROW-2;i>=0;i--)//hang { if(arr_Num[i][j]>-1&&arr_Num[i+1][j]==-1)//¬ª√ÅœÄÀö‚Äù‚Äú¬±Ô¨Ç¬†¬´√∏‚Äô¬µ∆? { over_check_move_up = true; } } } for (int j=0;j<MAX_COL;j++) { for (int i=MAX_ROW-1;i>0;i--) { if(arr_Num[i][j]>=0&&arr_Num[i][j]==arr_Num[i-1][j]) { over_check_heti_up = true; } } } if(!over_check_move_up&&!over_check_heti_up) isUpOver = true; //check-down for (int j =0; j < MAX_COL ; j++)//lie { for (int i= 1;i< MAX_ROW;i++)//hang { if(arr_Num[i][j]>-1&&arr_Num[i-1][j]==-1)//¬ª√ÅœÄÀö‚Äù‚Äú¬±Ô¨Ç¬†¬´√∏‚Äô¬µ∆? { over_check_move_down = true; } } } for (int j=0;j<MAX_COL;j++) { for (int i=0;i<MAX_ROW-1;i++) { if(arr_Num[i][j]>=0&&arr_Num[i][j]==arr_Num[i+1][j]) { over_check_heti_down = true; } } } if(!over_check_move_down&&!over_check_heti_down) isDownOver = true; MyCCLog::verbose("isUpOver = %d isDownOver = %d isLeftOver = %d isRightOver= %d",isUpOver,isDownOver,isLeftOver,isRightOver); if(isUpOver&&isDownOver&&isLeftOver&&isRightOver){ CCLog("game----over------over"); game_state = GAME_OVER; PopupLayer* popLayer = PopupLayer::create("2048/gameover_bg.png"); popLayer->setContentSize(CCSizeMake(400,400)); popLayer->setTitle("Game Over",20); popLayer->setCallbackFunc(this,callfuncN_selector(T2::gameover_btnCallback)); popLayer->addButton("2048/restart.png", "2048/restart.png", "",0); popLayer->addButton("2048/exit.png", "2048/exit.png", "",1); this->addChild(popLayer); return true; } return false; }