void Powerup::update() { if (GameState::getInt(mKind) != 0) { return; } Hero *hero = getRoom()->getHero(); Entity::CollisionRect cr = hero->getCollisionRect(); if (Collides(getCollisionRect(), cr)) { GameState::put(mKind, 1); std::string explanation; PowerUpScreen* screen; if (mKind == GameState::POWERUP_HIJUMP) { screen = new PowerUpScreen("HI JUMP SOCKS", "JUMP HIGHER"); } else if (mKind == GameState::POWERUP_GUN) { screen = new PowerUpScreen("POWER GUN", "USE Z"); } else if (mKind == GameState::POWERUP_GRENADE) { screen = new PowerUpScreen("GRAVITY GRANADE", "USE X"); } ScreenManager::add(screen); } mFrame++; }
void CGE2Engine::pocFul() { Hero *h = _heroTab[_sex]->_ptr; h->park(); _commandHandler->addCommand(kCmdWait, -1, -1, h); _commandHandler->addCommand(kCmdSound, -1, 2, h); _commandHandler->addCommand(kCmdSay, -1, kPocketFull + _sex, h); }
// on "init" you need to initialize your instance bool BackgroundLayer::init() { ////////////////////////////// // 1. super init first if (!Layer::init()) { return false; } Size visibleSize = Director::getInstance()->getVisibleSize(); Point origin = Director::getInstance()->getVisibleOrigin(); Sprite *pSprite = Sprite::create("background2.png"); //pSprite->setOpacity(0.0); // position the sprite on the center of the screen pSprite->setPosition(Point(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y)); // add the sprite as a child to this layer this->addChild(pSprite, 0); //Create a "one by one" touch event listener (processes one touch at a time) auto listener1 = EventListenerTouchOneByOne::create(); // When "swallow touches" is true, then returning 'true' from the onTouchBegan method will "swallow" the touch event, preventing other listeners from using it. listener1->setSwallowTouches(true); // Example of using a lambda expression to implement onTouchBegan event callback function listener1->onTouchBegan = [](Touch* touch, Event* event) { // event->getCurrentTarget() returns the *listener's* sceneGraphPriority node. auto target = static_cast<Sprite*>(event->getCurrentTarget()); //Get the position of the current point relative to the button Point locationInNode = target->convertToNodeSpace(touch->getLocation()); Size s = target->getContentSize(); Rect rect = Rect(0, 0, s.width, s.height); //Check the click area if (rect.containsPoint(locationInNode)) { /* Color4B *buffer = (Color4B *)malloc(sizeof(Color4B)); Point location = Point(locationInNode.x * CC_CONTENT_SCALE_FACTOR(), locationInNode.y * CC_CONTENT_SCALE_FACTOR()); glReadPixels(location.x,location.y, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, buffer); Color4B color = buffer[0]; log("sprite began... x = %f, y = %f pColor=%d %d %d %d", locationInNode.x, locationInNode.y, color.r, color.g, color.b, color.a); */ Hero *hero = FirstScene::getInstance()->getGameObjectsLayer()->getHero(); hero->go(locationInNode); return true; } return false; }; _eventDispatcher->addEventListenerWithSceneGraphPriority(listener1, pSprite); return true; }
void Camera::UpdateHeroFollow( float dt ) { //if hero hasn't moved this frame, return Hero* hero = g_game->GetWorld()->GetHero(); if(hero->MovedLastFrame() == false) { return; } //try to focus on hero Vec2f oldCenter = m_quad.Center(); Vec2f toHero = g_game->GetWorld()->GetHero()->GetMoveCenter() - m_quad.Center(); float oldDistance = toHero.Length(); toHero.Normalize(); m_quad.Offset(toHero * kCameraMoveSpeed * dt); float distanceMoved = (m_quad.Center() - oldCenter).Length(); if(distanceMoved > oldDistance) { //overshoot m_quad.SetCenter(g_game->GetWorld()->GetHero()->GetMoveCenter()); } //constrain to room m_quad.ClipInsideOtherQuad(m_room->RoomQuad()); }
void Robot::UseSkill() { if (!startattack) { HGE *hge = hgeCreate(HGE_VERSION); float x, y; hge->Input_GetMousePos(&x, &y); backx = GetX(); backy = GetY(); switch (coretype) { //攻击型 //开始攻击 case Attack: if (x<ACT_START_X || x>ACT_END_X || y<ACT_START_Y || y>ACT_END_Y) { if (!tremble) tremble = 20; return; } else { SetCollisionRange(40); SetPos(x, y); } break; //触发技能型 //跟hero做intercation将自身赋给hero然后自杀 case Magic: break; //BUFF型 //施放技能 case Buff: { int count = 0; Hero *a = dynamic_cast<Hero*>(ObjectPool::GetObjPool().GetOurHero(GetType())); for (int i = 0; i < STD_CORES; i++) { Robot *b = dynamic_cast<Robot*>(a->GetCOREs(i)); if (b && b->IsActive()) { if (b->GetInnerCode() == GetInnerCode()) { b->Suicide(); a->Interaction(b); } else if (b->GetCoreType() == Buff) count++; } } SetSpeed(1500); SetAim(25 + count * 50, 175); } break; } startattack = true; } }
/** * \brief Creates an arrow. * \param hero The hero. */ Arrow::Arrow(const Hero& hero): Entity("", 0, hero.get_layer(), Point(0, 0), Size(0, 0)), hero(hero) { // initialize the entity int direction = hero.get_animation_direction(); create_sprite("entities/arrow", true); get_sprite().set_current_direction(direction); set_drawn_in_y_order(true); if (direction % 2 == 0) { // Horizontal. set_size(16, 8); set_origin(8, 4); } else { // Vertical. set_size(8, 16); set_origin(4, 8); } set_xy(hero.get_center_point()); notify_position_changed(); std::string path = " "; path[0] = '0' + (direction * 2); set_movement(std::make_shared<PathMovement>( path, 192, true, false, false )); disappear_date = System::now() + 10000; stop_now = false; entity_reached = nullptr; }
bool DataBase::_insertHero(const Hero &hero) { QSqlQuery query(_db); query.prepare("insert into Heroes (hero_id, name) values(?, ?)"); query.addBindValue(hero.getId()); query.addBindValue(hero.getName()); return query.exec(); }
void PopGameApp::keyUp(KeyEvent event) { if(event.getCode () == KeyEvent::KEY_UP) { plane->setKey(1,0); }else if(event.getCode () == KeyEvent::KEY_DOWN) { plane->setKey(1,1); }else if(event.getCode () == KeyEvent::KEY_LEFT) { plane->setKey(1,2); }else if(event.getCode () == KeyEvent::KEY_RIGHT) { plane->setKey(1,3); }else if(event.getCode () == KeyEvent::KEY_SPACE) { plane->setKey(1,4); } }
/** * \brief Creates an arrow. * \param hero The hero. */ Arrow::Arrow(const Hero& hero): MapEntity("", 0, hero.get_layer(), 0, 0, 0, 0), hero(hero) { // initialize the entity int direction = hero.get_animation_direction(); create_sprite("entities/arrow", true); get_sprite().set_current_direction(direction); set_drawn_in_y_order(true); if (direction % 2 == 0) { // Horizontal. set_size(16, 8); set_origin(8, 4); } else { // Vertical. set_size(8, 16); set_origin(4, 8); } set_xy(hero.get_center_point()); set_optimization_distance(0); // Make the arrow continue outside the screen until disappear_date. std::string path = " "; path[0] = '0' + (direction * 2); Movement* movement = new PathMovement(path, 192, true, false, false); set_movement(movement); disappear_date = System::now() + 10000; stop_now = false; entity_reached = NULL; }
void Savepoint::update() { mFrame++; if (mTextCounter > 0) { mTextCounter--; } Hero *hero = getRoom()->getHero(); Entity::CollisionRect cr= hero->getCollisionRect(); bool heroOn = Collides(getCollisionRect(), cr); if (heroOn && !mHeroOn) { // SAVE GameState::put(GameState::LOCATION_X, getRoom()->getWorldOffsetX() * getRoom()->getTileWidth() + this->getPosition().x); GameState::put(GameState::LOCATION_Y, getRoom()->getWorldOffsetY() * getRoom()->getTileHeight() + this->getPosition().y + 10); GameState::saveToFile(); Sound::playSample("data/sounds/coin.wav"); mTextCounter = 50; } mHeroOn = heroOn; }
// let a hero win the game int Script::winHero(lua_State* L){ short x = (short)luaL_checknumber(L, 1); short y = (short)luaL_checknumber(L, 2); Hero* h = dynamic_cast<Hero*>(wrld.getObject(Vector2D(x,y))); h->win(); return 0; }
int Scene_Server_Request::process_20410001(int cid, role_id_t role_id, Scene_Player *player, Block_Buffer &buf) { JUDGE_PLAYER_NULL(player, role_id); MSG_50200032 res_msg; res_msg.role_id = player->role_id(); res_msg.open_type = 1; player->fighter_detail().property_list(res_msg.prop_value); Hero *hero = SCENE_PUBLIC->find_fight_hero(player->role_id()); if (hero) { int hero_init_morale_type = hero->fighter_detail().init_morale.type; double hero_init_morale_val = hero->fighter_detail().init_morale.total(); for (uint16_t i = 0; i < res_msg.prop_value.size(); ++i) { if (res_msg.prop_value[i].type == hero_init_morale_type) { res_msg.prop_value[i].value += hero_init_morale_val; } } } res_msg.prop_value.push_back(Property(PT_CAREER, player->career())); res_msg.role_name = player->role_name();/*人物姓名*/ res_msg.gang_name = player->base_detail().gang_name;/*人物id*/ res_msg.gender = player->base_detail().gender;/*性别(1男,2女)*/ res_msg.gang_id = player->base_detail().gang_id;/*职业*/ res_msg.headship = player->ganger_detail().headship; res_msg.avatar_vec = player->base_detail().avatar_vec; OBJ_SEND_TO_CLIENT(res_msg, (*player)); return 0; }
int Scene_Server_Request::process_20100503(int cid, role_id_t role_id, Scene_Player *player, Block_Buffer &buf) { JUDGE_PLAYER_NULL(player, role_id); int8_t type = 0; uint16_t len = 0; buf.read_int8(type); buf.read_uint16(len); if (len <= 0) { return 0; } // player Hero *hero = SCENE_PUBLIC->find_fight_hero(role_id); if (!hero) { return 0; } if (type == 1) { // add for (uint16_t i = 0; i < len; ++i) { hero->inner_status_insert(buf); } } else { Int_Hash_Set is; int status_id = 0; for (uint16_t i = 0; i < len; ++i) { buf.read_int32(status_id); is.insert(status_id); } hero->erase_status_in_set(is); } return 0; }
//conducts the battle between player and enemy also increments or decrements gold void battle(KillCount& kMap, Hero<int> &hero, Enemy<int> &e, int &gold){ cout << endl; //show enemy stats and players stats before player chooses weapon cout << "Now battling " << e.getName() << " " << e.getID() << " carrying " << e.getEgold() << " gold" << endl; cout << "Enemy has " << e.getAttk() << " attack" << endl; cout << hero.getName() << " has " << hero.getAttack() << endl; //player attack after the have chosen a weapon int heroBattleAttk = hero.getAttack() + hero.boost(); //show player attack after they have chosen a weapon cout << hero.getName() << " Attack become " << heroBattleAttk << endl; if(e.getAttk() > heroBattleAttk){ //if enemy has more attack player loses gold equal to amount carried by enemy cout << "You have lost battle " << e.getEgold() << " gold lost" << endl; gold -= e.getEgold(); cout << "Gold count now: " << gold << endl; }else if(e.getAttk() < heroBattleAttk){ //if player has more attack than enemy player gains gold gold carried by enemy cout << "You have won battle " << e.getEgold() << " gold gained" << endl; gold += e.getEgold(); kMap.incrementCount(e.getName()); cout << "Gold count now: " << gold << endl; }else{ //if tie no gold won or lost cout << "Battle is a tie no gold gained or lost" << endl; gold +=0; cout << "Gold count now: " << gold << endl; } }
int Scene_Server_Request::process_20400003(int cid, role_id_t role_id, Scene_Player *player, Block_Buffer &buf) { JUDGE_PLAYER_NULL(player, role_id); MSG_20400003 msg; msg.deserialize(buf); Hero *hero = SCENE_PUBLIC->find_master_id_hero(role_id); if (! hero) { //MSG_USER("hero fight, can't find hero, master_id = %ld, is_out = %d", msg.master_role_id, msg.is_out); // 登陆时会到这里 return -1; } // 出战 if (msg.is_out) { if (player->is_in_battle()) { //player->hero_battle_birth(); } else if (player->move_scene()) { if (player->move_scene()->scene_type() == War_Scene_Type) { return 0; } const Coord &player_coord = player->mover_detail().grid_coord; if (0 != hero->birth(hero->hero_const_base_detail().hero_role_id, player->move_scene(), player_coord)) { hero->outer_hero_recycle(); return -1; } } // 收回 } else { hero->outer_hero_recycle(); } return 0; }
//释放按键 void Keyboard::onKeyRelease(EventKeyboard::KeyCode keycode, Event* event){ Hero* hero = global->hero; if (keycode == EventKeyboard::KeyCode::KEY_LEFT_ARROW){ m_bKeyState[KEY_STATE_LEFT_ARROW] = false; hero->CheckKeyState(); } else if (keycode == EventKeyboard::KeyCode::KEY_RIGHT_ARROW){ m_bKeyState[KEY_STATE_RIGHT_ARROW] = false; hero->CheckKeyState(); } else if (keycode == EventKeyboard::KeyCode::KEY_DOWN_ARROW){ hero->onStandup(); m_bKeyState[KEY_STATE_DOWN_ARROW] = false; } else if (keycode == EventKeyboard::KeyCode::KEY_UP_ARROW){ m_bKeyState[KEY_STATE_UP_ARROW] = false; } else if (keycode == EventKeyboard::KeyCode::KEY_SPACE){ m_bKeyState[KEY_STATE_SPACE] = false; } else if (keycode == EventKeyboard::KeyCode::KEY_LEFT_CTRL){ m_bKeyState[KEY_STATE_LEFT_CTRL] = false; } else if (keycode == EventKeyboard::KeyCode::KEY_Z){ m_bKeyState[KEY_STATE_Z] = false; } }
void Enemy::move(Mode::Engine *engine) { Hero *hero = engine->getData<Actors>()->getHero(0); rotate(hero); _x += (_speed * cos(_theta + 3.1415/4))/engine->getInstFps(); _y -= (_speed * sin(_theta + 3.1415/4))/engine->getInstFps(); for(int i = 0; i < engine->getData<Actors>()->getHeroAmt(); ++i) { if(!_dead && !engine->getData<Actors>()->getHeros()->empty()) { hero = engine->getData<Actors>()->getHero(i); std::vector<Bullet*> *bullet = hero->getBullet(); for(int i = (bullet->size() > 400) ? bullet->size() - 400 : 0; i < bullet->size(); ++i) { if(bullet->at(i)->getX() > _x && bullet->at(i)->getX() < _x + _h && bullet->at(i)->getY() > _y && bullet->at(i)->getY() < _y + _h) { if(_health > 0) { _health-=guns[bullet->at(i)->getType()].damage; } else { _dead = true; ++engine->getData<Actors>()->heroKills; ++engine->getData<Actors>()->heroPoints; _x = 0; _y = 0; _w = 0; _h = 0; } bullet->at(i)->die(); } } } } }
/** * \brief Attacks the hero if possible. * * This function is called when there is a collision between the enemy and the hero. * * \param hero the hero * \param this_sprite the sprite of this enemy that detected the collision with the hero, * or NULL if it was not a pixel-precise collision. */ void Enemy::attack_hero(Hero &hero, Sprite *this_sprite) { if (!is_immobilized() && can_attack && hero.can_be_hurt(this)) { bool hero_protected = false; if (minimum_shield_needed != 0 && get_equipment().has_ability("shield", minimum_shield_needed)) { // compute the direction corresponding to the angle between the enemy and the hero double angle = hero.get_angle(*this); int protected_direction4 = (int) ((angle + Geometry::PI_OVER_2 / 2.0) * 4 / Geometry::TWO_PI); protected_direction4 = (protected_direction4 + 4) % 4; // also get the direction of the enemy's sprite int sprite_opposite_direction4 = -1; if (this_sprite != NULL) { sprite_opposite_direction4 = (this_sprite->get_current_direction() + 2) % 4; } // the hero is protected if he is facing the opposite of one of these directions hero_protected = hero.is_facing_direction4(protected_direction4) || hero.is_facing_direction4(sprite_opposite_direction4); } if (hero_protected) { attack_stopped_by_hero_shield(); } else { hero.hurt(*this, damage_on_hero, magic_damage_on_hero); } } }
/************************************************************************************** VERIFY WIN/LOSE CONDITION **************************************************************************************/ void verifyWinLose() { if(score_points >= WIN_CONDITION) { end_game = GL_TRUE; } if(end_game) { game_speed = 0.0f; move_text(score_txtLabel, -0.15, 0.2f); if(score_points >= WIN_CONDITION) { score = "You WIN!"; hero.win(dt); } else { score = "You LOSE!"; if(jumps == 0) { hero.setVelocity(60.0f); jumps++; } for(int i=0; i<NUMBER_OF_MONSTERS; i++) monster[i].stop = 0.0f; hero.die(dt); if(camera_loops < 1 && hero.died) { camera.setSpeedRotation(3.0f); camera.rotation360(); camera_loops++; } } } }
/* * Listens to key press events from the graphical subsystem, * and handles the events appropriately: * - '[n]' moves hero in direction [n], * where n = 1, 2, 3, 4, 6, 7, 8, 9 on the numeric keypad * - '5' on the numeric keypad makes the hero wait one turn * - 'T' teleports hero */ void MainWindow::keyPressEvent(QKeyEvent *e) { if (!gameOver) { // only process key presses while game is not over Hero hero = gameState.getHero(); Point pt = hero.asPoint(); bool actionTaken = false; bool waiting = false; if (e->modifiers() == Qt::KeypadModifier) { switch (e->key()) { case Qt::Key_1: actionTaken = tryMove(hero, Point{pt.x - 1, pt.y + 1}); break; case Qt::Key_2: actionTaken = tryMove(hero, Point{pt.x, pt.y + 1}); break; case Qt::Key_3: actionTaken = tryMove(hero, Point{pt.x + 1, pt.y + 1}); break; case Qt::Key_4: actionTaken = tryMove(hero, Point{pt.x - 1, pt.y}); break; case Qt::Key_6: actionTaken = tryMove(hero, Point{pt.x + 1, pt.y}); break; case Qt::Key_7: actionTaken = tryMove(hero, Point{pt.x - 1, pt.y - 1}); break; case Qt::Key_8: actionTaken = tryMove(hero, Point{pt.x, pt.y - 1}); break; case Qt::Key_9: actionTaken = tryMove(hero, Point{pt.x + 1, pt.y - 1}); break; case Qt::Key_5: actionTaken = true; waiting = true; break; default: QWidget::keyPressEvent(e); } } else { switch (e->key()) { case Qt::Key_T: gameState.teleportHero(); actionTaken = true; break; default: QWidget::keyPressEvent(e); } } if (actionTaken) { // process results of viable move processMove(waiting); } } else { // game is over - do not process key press QWidget::keyPressEvent(e); } }
//------------------------------------------------------------------------------------- Hero* Cenario::iniciarHero(){ Hero* hero = new Hero(); hero->setNode( Bomberman::getInstance()->mSceneMgr->getSceneNode( "bomberman_node" ) ); hero->setEntity( Bomberman::getInstance()->mSceneMgr->getEntity( "bomberman" ) ); return hero; }
void Spike::update() { Hero* hero = mRoom->getHero(); if (Collides(hero->getCollisionRect(), getCollisionRect())) { hero->kill(); } }
void enemyTurn(Hero& hero, ArmoredEnemy& enemy) { std::this_thread::sleep_for(std::chrono::milliseconds(500)); hero.setHealth(hero.getBool() ? hero.getHealth() < static_cast<unsigned short>(enemy.getAttack() * 0.1) ? 0 : hero.getHealth() - static_cast<unsigned short>(enemy.getAttack() * 0.1) : hero.getHealth() < enemy.getAttack() ? 0 : hero.getHealth() - enemy.getAttack()); // If the hero is blocking only do 1/10th damage if(enemy.getBool()) enemy.setBool(false); // Resetting blocking bool if(rand() % 10 + 1 == 10) enemy.setBool(true); }
Hero* Hero::create(b2World *world) { Hero* ret = new Hero(); if (ret && ret->initWithWorld(world)) { return ret; } return nullptr; }
Computer::Computer(Hero& temp) { position = temp.get_position(); prev_position = position; character = temp.get_character(); step = temp.get_step(); review = temp.get_review(); sign = temp.get_sign(); }
/************************************************************************************** INPUT HANDLING **************************************************************************************/ void inputHandling(GLFWwindow* window) { if(GLFW_PRESS == glfwGetKey(window, GLFW_KEY_ESCAPE)) { exit(0); } if(GLFW_PRESS == glfwGetKey(window, GLFW_KEY_LEFT) && !end_game) { left_pressed = GL_TRUE; } if(GLFW_RELEASE == glfwGetKey(window, GLFW_KEY_LEFT)) { if(left_pressed) { hero.rotate_left(); left_pressed = GL_FALSE; } } if(GLFW_PRESS == glfwGetKey(window, GLFW_KEY_RIGHT) && !end_game) { right_pressed = GL_TRUE; } if(GLFW_RELEASE == glfwGetKey(window, GLFW_KEY_RIGHT)) { if(right_pressed) { hero.rotate_right(); right_pressed = GL_FALSE; } } if(GLFW_PRESS == glfwGetKey(window, GLFW_KEY_UP)) { up_pressed = GL_TRUE; } if(GLFW_RELEASE == glfwGetKey(window, GLFW_KEY_UP)) { if(up_pressed) { game_speed += 1.0f; up_pressed = GL_FALSE; } } if(GLFW_PRESS == glfwGetKey(window, GLFW_KEY_W)) { camera.cameraUp(); } if(GLFW_PRESS == glfwGetKey(window, GLFW_KEY_S)) { camera.cameraDown(); } if(GLFW_PRESS == glfwGetKey(window, GLFW_KEY_P)) { game_speed = 0.0f; additional_speed = 0.0f; hero.toRotate = 270; } if(GLFW_PRESS == glfwGetKey(window, GLFW_KEY_R)) { camera.rotation360(); } }
/** * \brief Makes the teletransporter move the hero to the destination. * \param hero the hero */ void Teletransporter::transport_hero(Hero& hero) { if (transporting_hero) { // already done return; } std::string name = destination_name; int hero_x = hero.get_x(); int hero_y = hero.get_y(); if (is_on_map_side()) { // special destination point: side of the map // we determine the appropriate side based on the teletransporter's position; // we also place the hero on the old map so that its position corresponds to the new map switch (destination_side) { case 0: name += '0'; // scroll to the west hero_x = 0; break; case 1: name += '1'; // scroll to the south hero_y = get_map().get_height() + 5; break; case 2: name += '2'; // scroll to the east hero_x = get_map().get_width(); break; case 3: name += '3'; // scroll to the north hero_y = 5; break; default: Debug::die(std::string("Bad destination side for teletransporter '") + get_name() + "'"); } } transporting_hero = true; get_lua_context()->teletransporter_on_activated(*this); if (!sound_id.empty()) { Sound::play(sound_id); } get_game().set_current_map(destination_map_id, name, transition_style); hero.set_xy(hero_x, hero_y); }
//解析从cdkey Server返回的消息 void acceptCdkeySrv(char *buffer) { if (sock_fd != cdKeySrvFd) { return; } cout<<"the sizeof buff:"<<strlen(buffer)<<endl; char *userName; char *cdKeyId; char *heroId; char failReason[100] = {0}; char *flag; MSG_BEGIN(buffer,g_msg_len); // MSG_CHAR(userName); MSG_CHAR(heroId); // MSG_CHAR(cdKeyId); // MSG_CHAR_END(flag); Hero *myHero = heroid_to_hero(heroId); if(myHero == NULL) { cout<<"the hero is NUll:"<<heroId<<endl; return; } cout<<"userName:"******"heroId:"<<heroId<<endl; cout<<"cdKeyId:"<<cdKeyId<<endl; cout<<"flag:"<<flag<<endl; if(strncmp(flag,"0",1) == 0) { /*激活码错误*/ snprintf(failReason,sizeof(failReason),"%d,%d,0",28,3); send_msg(myHero->getFd(),failReason); cout<<"the activeCodeId is error:"<<cdKeyId<<endl; } else if(strncmp(flag,"1",1) == 0) { /*激活码已被使用*/ snprintf(failReason,sizeof(failReason),"%d,%d,1",28,3); send_msg(myHero->getFd(),failReason); cout<<"the activeCodeId is used by other:"<<cdKeyId<<endl; } //已使用激活码 else if(strncmp(flag,"2",1) == 0) { snprintf(failReason,sizeof(failReason),"%d,%d,2",28,3); send_msg(myHero->getFd(),failReason); } }
Hero* Hero::heroWithGame(GameLayer* game) { Hero* hero = new Hero(game); if (hero) { hero->autorelease(); return hero; } return NULL; }
Hero *Hero::heroWithinLayer() { Hero *pRet = new Hero(); if(pRet && pRet->heroInit()) { pRet->autorelease(); return pRet; } CC_SAFE_DELETE(pRet); return NULL; }