bool FormatContext::getReplayGain(bool album, float &gain_db, float &peak) const { const int streamIdx = av_find_best_stream(formatCtx, AVMEDIA_TYPE_AUDIO, -1, -1, nullptr, 0); if (streamIdx > -1) { if (void *sideData = av_stream_get_side_data(streams[streamIdx], AV_PKT_DATA_REPLAYGAIN, nullptr)) { AVReplayGain replayGain = *(AVReplayGain *)sideData; qint32 tmpGain; quint32 tmpPeak; if (replayGain.album_gain == INT32_MIN && replayGain.track_gain != INT32_MIN) replayGain.album_gain = replayGain.track_gain; if (replayGain.album_gain != INT32_MIN && replayGain.track_gain == INT32_MIN) replayGain.track_gain = replayGain.album_gain; if (replayGain.album_peak == 0 && replayGain.track_peak != 0) replayGain.album_peak = replayGain.track_peak; if (replayGain.album_peak != 0 && replayGain.track_peak == 0) replayGain.track_peak = replayGain.album_peak; if (album) { tmpGain = replayGain.album_gain; tmpPeak = replayGain.album_peak; } else { tmpGain = replayGain.track_gain; tmpPeak = replayGain.track_peak; } if (tmpGain == INT32_MIN) return false; gain_db = tmpGain / 100000.0; if (tmpPeak != 0) peak = tmpPeak / 100000.0; return true; } } if (AVDictionary *dict = getMetadata()) { QString album_gain_db = getTag(dict, "REPLAYGAIN_ALBUM_GAIN", false); QString album_peak = getTag(dict, "REPLAYGAIN_ALBUM_PEAK", false); QString track_gain_db = getTag(dict, "REPLAYGAIN_TRACK_GAIN", false); QString track_peak = getTag(dict, "REPLAYGAIN_TRACK_PEAK", false); if (album_gain_db.isEmpty() && !track_gain_db.isEmpty()) album_gain_db = track_gain_db; if (!album_gain_db.isEmpty() && track_gain_db.isEmpty()) track_gain_db = album_gain_db; if (album_peak.isEmpty() && !track_peak.isEmpty()) album_peak = track_peak; if (!album_peak.isEmpty() && track_peak.isEmpty()) track_peak = album_peak; QString str_gain_db, str_peak; if (album) { str_gain_db = album_gain_db; str_peak = album_peak; } else { str_gain_db = track_gain_db; str_peak = track_peak; } int space_idx = str_gain_db.indexOf(' '); if (space_idx > -1) str_gain_db.remove(space_idx, str_gain_db.length() - space_idx); bool ok; float tmp = str_peak.toFloat(&ok); if (ok) peak = tmp; tmp = str_gain_db.toFloat(&ok); if (ok) gain_db = tmp; return ok; } return false; }
StreamInfo *FormatContext::getStreamInfo(AVStream *stream) const { if (streamNotValid(stream)) return nullptr; StreamInfo *streamInfo = new StreamInfo; if (const AVCodec *codec = avcodec_find_decoder(stream->codecpar->codec_id)) streamInfo->codec_name = codec->name; streamInfo->must_decode = true; if (const AVCodecDescriptor *codecDescr = avcodec_descriptor_get(stream->codecpar->codec_id)) { if (codecDescr->props & AV_CODEC_PROP_TEXT_SUB) streamInfo->must_decode = false; if (streamInfo->codec_name.isEmpty()) streamInfo->codec_name = codecDescr->name; } streamInfo->bitrate = stream->codecpar->bit_rate; streamInfo->bpcs = stream->codecpar->bits_per_coded_sample; streamInfo->codec_tag = stream->codecpar->codec_tag; streamInfo->is_default = stream->disposition & AV_DISPOSITION_DEFAULT; streamInfo->time_base.num = stream->time_base.num; streamInfo->time_base.den = stream->time_base.den; streamInfo->type = (QMPlay2MediaType)stream->codecpar->codec_type; //Enumy są takie same if (stream->codecpar->extradata_size) { streamInfo->data.reserve(stream->codecpar->extradata_size + AV_INPUT_BUFFER_PADDING_SIZE); streamInfo->data.resize(stream->codecpar->extradata_size); memcpy(streamInfo->data.data(), stream->codecpar->extradata, streamInfo->data.capacity()); av_free(stream->codecpar->extradata); stream->codecpar->extradata = (quint8 *)streamInfo->data.data(); } if (streamInfo->type != QMPLAY2_TYPE_ATTACHMENT) { QString value; if (streamsInfo.count() > 1) { streamInfo->title = getTag(stream->metadata, "title"); streamInfo->artist = getTag(stream->metadata, "artist"); if (!(value = getTag(stream->metadata, "album")).isEmpty()) streamInfo->other_info += {QString::number(QMPLAY2_TAG_ALBUM), value}; if (!(value = getTag(stream->metadata, "genre")).isEmpty()) streamInfo->other_info += {QString::number(QMPLAY2_TAG_GENRE), value}; if (!(value = getTag(stream->metadata, "date")).isEmpty()) streamInfo->other_info += {QString::number(QMPLAY2_TAG_DATE), value}; if (!(value = getTag(stream->metadata, "comment")).isEmpty()) streamInfo->other_info += {QString::number(QMPLAY2_TAG_COMMENT), value}; } if (!(value = getTag(stream->metadata, "language", false)).isEmpty() && value != "und") streamInfo->other_info += {QString::number(QMPLAY2_TAG_LANGUAGE), value}; } switch (streamInfo->type) { case QMPLAY2_TYPE_AUDIO: streamInfo->format = av_get_sample_fmt_name((AVSampleFormat)stream->codecpar->format); streamInfo->channels = stream->codecpar->channels; streamInfo->sample_rate = stream->codecpar->sample_rate; streamInfo->block_align = stream->codecpar->block_align; break; case QMPLAY2_TYPE_VIDEO: { streamInfo->format = av_get_pix_fmt_name((AVPixelFormat)stream->codecpar->format); if (stream->sample_aspect_ratio.num) streamInfo->sample_aspect_ratio = av_q2d(stream->sample_aspect_ratio); else if (stream->codecpar->sample_aspect_ratio.num) streamInfo->sample_aspect_ratio = av_q2d(stream->codecpar->sample_aspect_ratio); streamInfo->W = stream->codecpar->width; streamInfo->H = stream->codecpar->height; if (!stillImage) streamInfo->FPS = av_q2d(stream->r_frame_rate); bool ok = false; const double rotation = getTag(stream->metadata, "rotate", false).toDouble(&ok); if (ok) streamInfo->rotation = rotation; if (void *sideData = av_stream_get_side_data(stream, AV_PKT_DATA_SPHERICAL, nullptr)) { streamInfo->spherical = (((AVSphericalMapping *)sideData)->projection == AV_SPHERICAL_EQUIRECTANGULAR); } break; } case QMPLAY2_TYPE_ATTACHMENT: streamInfo->title = getTag(stream->metadata, "filename", false); switch (stream->codecpar->codec_id) { case AV_CODEC_ID_TTF: streamInfo->codec_name = "TTF"; break; case AV_CODEC_ID_OTF: streamInfo->codec_name = "OTF"; break; default: break; } break; default: break; } return streamInfo; }
bool SelectPerson::init(){ if (!LayerColor::initWithColor(Color4B(0, 0, 0, 150))){ return false; } //背景 ui::ImageView* img = ui::ImageView::create("person.png"); //Size(274, 374) img->setPosition(Vec2(320, 568)); this->addChild(img); //创建ui::ScrollView 垂直方向 ui::ScrollView* scrollView = ui::ScrollView::create(); //ScrollView锚点默认是(0, 0) scrollView->setBounceEnabled(true); scrollView->setClippingEnabled(true); //默认是true scrollView->setDirection(ui::ScrollView::Direction::VERTICAL); scrollView->setContentSize(Size(250, 300)); scrollView->setPosition(Vec2(10, 60)); img->addChild(scrollView); //从数据库中取出的值 现在暂时写好 等后期再改*** std::vector<std::string> nameVec = { "ZhangSan", "LiSi", "WangWu", "ZhaoLiu", "QianQi", "TangYi", "QiuXiang" }; //行信息 //这里加载的时候会比较慢 什么原因 怎么解决加载慢的问题呢 每一行都是要加载checkbox text 使用ui控件比较容易些 for (size_t i = 0; i < nameVec.size(); i++) { auto row = Row::createWithName(nameVec.at(i)); row->setPosition(Vec2(0, scrollView->getContentSize().height - i * 50)); row->setTag(ROW_TAG + i); scrollView->addChild(row); rowVec.pushBack(row); } scrollView->setInnerContainerSize(Size(scrollView->getContentSize().width, 50 * nameVec.size())); //添加提示标签 _tip = ui::Text::create(); _tip->setString(StringUtils::format(Chinese::getInstance()->ChineseWord("tip").c_str(), 4)); _tip->setFontSize(20); _tip->setPosition(Vec2(10, 20)); _tip->setAnchorPoint(Vec2::ZERO); img->addChild(_tip); //确认按钮 点击之后 读取所勾选的4个人物 从rowVec中读取选中的4项 ui::Button* button = ui::Button::create("btn_normal.png", "btn_select.png", "btn_disable.png"); button->setPosition(Vec2(img->getContentSize().width * 0.5 + 70, 40)); button->setTitleText("Certain"); button->setTitleFontSize(25); button->addClickEventListener([=](Ref* sender){ log("certain"); int count = 0; for (int i = 0; i < rowVec.size(); i++){ auto row = rowVec.at(i); if (row->getName() == "selected"){ log("row tag = %d", row->getTag()); //得到tag log("name = %s", nameVec.at(row->getTag() - ROW_TAG).c_str()); //得到name ++count; } } log("count = %d", count); scheduleOnce(schedule_selector(SelectPerson::discussResult), 180); //延迟启动计时器180s 也就是3分钟 //在等待的期间 我们怎么去处理这段时间应该做哪些事情呢 能不能做其他事情呢 还是只能静静的等待?? //应该列出一些对话内容 对话不能显示过快 第一条出现后隔5秒出现第二条,以此类推 }); img->addChild(button); _button = button; /* 怎么及时更新tip的内容呢,我每点击一个checkbox应当记录一个值 该值要相应的+1 */ schedule(schedule_selector(SelectPerson::updateData)); //schedule(SEL_SCHEDULE(&SelectPerson::updateData)); return true; }
bool BlockFS::hasTag(const std::string &name_or_id) const { return getTag(name_or_id) != nullptr; }
void RogueScene::touchEventExec(cocos2d::Point touchPoint) { auto pMapLayer = (TMXTiledMap*)getChildByTag(kTiledMapTag); // マップ移動分を考慮 MapIndex touchPointMapIndex = touchPointToIndex(touchPoint - pMapLayer->getPosition()); CCLOG("onTouchBegan touchPointMapIndex x = %d y = %d", touchPointMapIndex.x, touchPointMapIndex.y); // 画面外判定 if (isMapLayerOver(touchPointMapIndex)) { // タッチ判定とみなさない return; } // タッチした位置が有効なIndexか判定 MapIndex addMoveIndex = checkTouchEventIndex(touchPointMapIndex); if (addMoveIndex.x == 0 && addMoveIndex.y == 0) { // タッチ判定とみなさない return; } // キャラの向きを変更 auto pActorSprite = getPlayerActorSprite(1); pActorSprite->runMoveAction(addMoveIndex); // 敵をタッチした auto pEnemyMapItem = m_mapManager.getActorMapItem(&touchPointMapIndex); if (pEnemyMapItem->mapDataType == MapDataType::ENEMY) { auto pPlayerDto = pActorSprite->getActorDto(); auto pEnemyDto = getEnemyActorSprite(pEnemyMapItem->seqNo)->getActorDto(); int damage = BattleLogic::exec(pPlayerDto, pEnemyDto); // 攻撃イベント logMessage("%sの攻撃: %sに%dのダメージ", pPlayerDto->name.c_str(), pEnemyDto->name.c_str(), damage); } else { // 障害物判定 if (isTiledMapColisionLayer(touchPointMapIndex)) { // TODO: ぶつかるSE再生 logMessage("壁ドーン"); } else { changeGameStatus(GameStatus::PLAYER_ACTION); // アイテムに重なったときの拾う処理 auto pTouchPointMapItem = m_mapManager.getMapItem(&touchPointMapIndex); if (pTouchPointMapItem->mapDataType == MapDataType::MAP_ITEM) { // ドロップアイテムを拾う auto pDropMapItem = (DropMapItem*) pTouchPointMapItem; // TODO: 拾うSE再生 // itemを取得 auto pDropItemLayer = getChildByTag(RogueScene::kTiledMapTag)->getChildByTag(RogueScene::TiledMapTag::kTiledMapDropItemBaseTag); auto pDropItemSprite = (DropItemSprite*) pDropItemLayer->getChildByTag(RogueScene::TiledMapTag::kTiledMapDropItemBaseTag + pDropMapItem->seqNo); // メッセージログ auto pDropItemDto = pDropItemSprite->getDropItemDto(); logMessage("%sを拾った。", pDropItemDto->name.c_str()); // イベントリに追加する getItemWindowLayer()->addItemList(pDropItemDto); // mapManagerから消す m_mapManager.removeMapItem(pDropMapItem); // ミニマップを更新 auto pMiniMapLayer = getChildByTag(kMiniMapTag); pMiniMapLayer->removeChildByTag(pDropItemSprite->getTag()); // Map上からremoveする pDropItemLayer->removeChild(pDropItemSprite); } // 移動処理 moveMap(addMoveIndex, pActorSprite->getActorMapItem()->seqNo, pActorSprite->getActorMapItem()->mapDataType, CallFunc::create([this](void) { changeGameStatus(GameStatus::ENEMY_TURN); })); // コールバックまでgameStatusを更新はしない return; } } // TODO: 会話 // 会話イベント // ターン終了 changeGameStatus(GameStatus::ENEMY_TURN); }
void GameWorld::updategame(float dt){ //CCLOG("update game"); Vector<Plane*> targets2Delete; //CCLOG("111, _targets: %zd.", _targets.size()); Vector<Plane*>::iterator iter;//; for (iter = _targets.begin(); iter != _targets.end(); iter++) { // target的碰撞体积 Plane* target = dynamic_cast<Plane*>(*iter); Rect targetRect = target->boundingBox(); // plane的碰撞矩形 Rect planeRect = _myPlane->boundingBox(); // plane与target的碰撞检测 if(targetRect.intersectsRect(planeRect)){ if(target->getTag() == 4){ CCLOG("package\n"); // if package and plane collide //doubleBulletFlag = true; this->scheduleOnce(schedule_selector(GameWorld::setDoubleBulletFlagF), 5); targets2Delete.pushBack(target); } else { CCLOG("game end."); // if enemy and plane collide auto gameOverScene = GameOverScene::create(); gameOverScene->getLayer()->getLabel()->setString(" "); gameOverScene->getLayer()->setCurrentScore(score); // converts 'int' to 'string' std::stringstream ss; std::string str; ss<<score; ss>>str; const char *pHighScore = str.c_str(); // converts 'const char *' to 'int' const char *highScore = localStorageGetItem("high_score").c_str(); if(highScore != NULL ){ int highScoreInt = std::atoi(highScore); // If higher than the highest score ,your score will replace it; if(highScoreInt<score) CCLOG("high_score: %s.", pHighScore); localStorageSetItem("high_score", pHighScore); }else{ localStorageSetItem("high_score", pHighScore); CCLOG("high_score: %s.", pHighScore); } gameOverScene->getLayer()->getScore()->setString(pHighScore); Director::getInstance()->replaceScene(gameOverScene); } } //CCLOG("222, bullet: %zd.", _bullets.size()); Vector<Sprite*> bullets2Delete; Vector<Sprite*>::iterator iterB; //bullet与target的碰撞 for (iterB = _bullets.begin(); iterB != _bullets.end(); iterB++) { //CCARRAY_FOREACH(_bullets, bulletsIterator){ auto bullet = dynamic_cast<Sprite*>(*iterB); Rect bulletRect = bullet->boundingBox(); if(targetRect.intersectsRect(bulletRect)){ target->attacked++; //CCLOG("target attacked: %d.", target->attacked); bullets2Delete.pushBack(bullet); } } /* CCLOG("333"); for (iterB = bullets2Delete.begin(); iterB != bullets2Delete.end(); iter++) { //CCARRAY_FOREACH(bullets2Delete, bulletsIterator){ auto bullet = dynamic_cast<Sprite*>(*iterB); _bullets.eraseObject(bullet); this->removeChild(bullet); }*/ if(target->attacked >= target->attackedCount){ targets2Delete.pushBack(target); } bullets2Delete.clear(); } //CCLOG("444, targets2Delete: %zd.", targets2Delete.size()); for (iter = targets2Delete.begin(); iter != targets2Delete.end(); iter++) { //CCARRAY_FOREACH(targets2Delete, targetIterator){ auto target = dynamic_cast<Plane*>(*iter); _targets.eraseObject(target); if(target->getTag() == 1){ score+=10; }else if(target->getTag() == 2){ score+=20; }else if(target->getTag() == 3){ score+=50; //CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("explosion.mp3"); }else if(target->getTag() == 4){ CCLOG("target is the package"); this->scheduleOnce(schedule_selector(GameWorld::setDoubleBulletFlagF), 5); doubleBulletFlag = true; } this->removeChild(target); std::stringstream ss; std::string str; ss<<score; ss>>str; const char *p = str.c_str(); scoreLabel->setString(p); //CCLOG("888"); } targets2Delete.clear(); //CCLOG("555"); }
bool RogueScene::init() { // 1. super init first if ( !Layer::init() ) { return false; } // 乱数 srand((unsigned int)time(NULL)); // TouchEvent settings auto listener = EventListenerTouchOneByOne::create(); listener->setSwallowTouches(true); listener->onTouchBegan = CC_CALLBACK_2(RogueScene::onTouchBegan, this); listener->onTouchMoved = CC_CALLBACK_2(RogueScene::onTouchMoved, this); listener->onTouchEnded = CC_CALLBACK_2(RogueScene::onTouchEnded, this); // this->getEventDispatcher()->addEventListenerWithSceneGraphPriority(listener, this); this->getEventDispatcher()->addEventListenerWithFixedPriority(listener, 1); auto winSize = Director::getInstance()->getWinSize(); // --------------------- // タイルマップを生成 // --------------------- auto pTiledMap = TMXTiledMap::create("tmx/desert.tmx"); pTiledMap->setPosition(Point::ZERO); this->addChild(pTiledMap, RogueScene::zTiledMapIndex, RogueScene::kTiledMapTag); m_baseMapSize = pTiledMap->getMapSize(); m_baseTileSize = pTiledMap->getTileSize(); m_baseContentSize = pTiledMap->getContentSize(); m_mapManager.init(0, (int)m_baseMapSize.height, 0, (int)m_baseMapSize.width); // 使ってなかった // // フロントレイヤー // auto pFrontLayer = Layer::create(); // pTiledMap->addChild(pFrontLayer, // RogueScene::TiledMapIndex::zTiledMapFrontIndex, // RogueScene::TiledMapTag::kTiledMapFrontTag); // エネミーレイヤー auto pEnemyLayer = Layer::create(); pTiledMap->addChild(pEnemyLayer, RogueScene::TiledMapIndex::zTiledMapEnemyBaseIndex, RogueScene::TiledMapTag::kTiledMapEnemyBaseTag); // ドロップアイテムレイヤー auto pDropItemLayer = Layer::create(); pTiledMap->addChild(pDropItemLayer, RogueScene::TiledMapIndex::zTiledMapDropItemBaseIndex, RogueScene::TiledMapTag::kTiledMapDropItemBaseTag); // 障害物をmapManagerに適応する auto pColisionLayer = pTiledMap->getLayer("colision"); for (int x = 0; x < m_baseMapSize.width; x++) { for (int y = 0; y < m_baseMapSize.height; y++) { if (pColisionLayer->getTileAt(Point(x, y))) { MapIndex mapIndex = {x, y, MoveDirectionType::MOVE_NONE}; auto tileMapIndex = mapIndexToTileIndex(mapIndex); m_mapManager.addObstacle(&tileMapIndex); } } } // --------------------- // グリッド線を生成 // --------------------- auto draw = DrawNode::create(); draw->setPosition(Point::ZERO); // 線の太さと色 float lineSize = 1 * 0.5; Color4F color = Color4F::MAGENTA; // 縦線を引く for (int x = 1; x < m_baseMapSize.width; x++) { float xPoint = x * m_baseTileSize.width; draw->drawSegment(Point(xPoint, 0), Point(xPoint, m_baseContentSize.height), lineSize, color); } // 横線を引く for (int y = 1; y < m_baseMapSize.height; y++) { float yPoint = y * m_baseTileSize.height; draw->drawSegment(Point(0, yPoint), Point(m_baseContentSize.width, yPoint), lineSize, color); } // マップに追加 pTiledMap->addChild(draw, RogueScene::TiledMapIndex::zGridLineIndex, RogueScene::TiledMapTag::kGridLineTag); //------------------------- // ステータスバー? //------------------------- auto statusLayer = LayerColor::create(Color4B::BLACK); statusLayer->setContentSize(Size(winSize.width, m_baseTileSize.height * 0.8)); statusLayer->setPosition(Point(0, winSize.height - statusLayer->getContentSize().height)); // TODO: あとで更新する auto sampleText = LabelTTF::create(" --F Lv-- HP ---/--- 満腹度 ---/--- - G", GAME_FONT(16), 16); sampleText->setPosition(Point(sampleText->getContentSize().width / 2, statusLayer->getContentSize().height / 2)); statusLayer->addChild(sampleText); this->addChild(statusLayer, RogueScene::zStatusBarIndex, RogueScene::kStatusBarTag); // // 下のステータスバー2 // auto pStatusLayer2 = LayerColor::create(Color4B::BLACK); // pStatusLayer2->setContentSize(Size(m_baseTileSize.width, m_baseTileSize.height)); // pStatusLayer2->setPosition(Point(0, 0)); // // // TODO: アイコン表示するかな(ステータスバー2?) // auto pFaceSprite = Sprite::createWithSpriteFrame(SpriteFrame::create("actor_4_f.png", Rect(0, 0, 96, 96))); // float scale = 1.0f / 3.0f; // pFaceSprite->setScale(scale, scale); // // pFaceSprite->setContentSize(pFaceSprite->getContentSize() * scale); // // CCLOG("getContentSize (%f, %f) ", pFaceSprite->getContentSize().width, pFaceSprite->getContentSize().height); // // pFaceSprite->setPosition(Point(pFaceSprite->getContentSize().width / 2, pFaceSprite->getContentSize().height / 2)); // pFaceSprite->setPosition(Point(pFaceSprite->getContentSize().width * pFaceSprite->getScaleX() / 2, pFaceSprite->getContentSize().height * pFaceSprite->getScaleY() / 2)); // pStatusLayer2->addChild(pFaceSprite); // // this->addChild(pStatusLayer2, RogueScene::zStatusBar2Index, RogueScene::kStatusBar2Tag); //------------------------- // ゲームログ表示 //------------------------- // float startWidth = pFaceSprite->getContentSize().width * pFaceSprite->getScaleX(); auto pGameLogLayer = LayerColor::create(Color4B(0, 0, 0, 192)); pGameLogLayer->setContentSize(Size(winSize.width * 0.8, m_baseTileSize.height * 1.5)); pGameLogLayer->setPosition(winSize.width / 2 - pGameLogLayer->getContentSize().width / 2, 0); int baseFontSize = 10; auto pLogTextLabel = LabelTTF::create("", GAME_FONT(baseFontSize), baseFontSize, Size::ZERO, TextHAlignment::LEFT, TextVAlignment::TOP); pLogTextLabel->setPosition(Point(pLogTextLabel->getContentSize().width / 2 + pLogTextLabel->getFontSize() / 4, pGameLogLayer->getContentSize().height - pLogTextLabel->getContentSize().height / 2 - pLogTextLabel->getFontSize() / 4)); pGameLogLayer->addChild(pLogTextLabel); this->addChild(pGameLogLayer, RogueScene::zGameLogIndex, RogueScene::kGameLogTag); // ------------------------ // ミニマップ // ------------------------ // 青で半透明 auto miniMapLayer = LayerColor::create(Color4B(0, 0, 196, 128)); // 1/8サイズ miniMapLayer->setContentSize(Size(m_baseMapSize.width * m_baseTileSize.width / 8, m_baseMapSize.height * m_baseTileSize.height / 8)); // ステータスバーの下くらい miniMapLayer->setPosition(0, miniMapLayer->getPositionY() + winSize.height - miniMapLayer->getContentSize().height - statusLayer->getContentSize().height); this->addChild(miniMapLayer, RogueScene::zMiniMapIndex, RogueScene::kMiniMapTag); // ------------------------ // イベントリ作成 // ------------------------ showItemList(1); hideItemList(); // --------------------- // プレイヤー生成 // --------------------- ActorSprite::ActorDto actorDto; actorDto.name = "ジニー"; actorDto.faceImgId = 0; actorDto.imageResId = 1015; // 基本 actorDto.attackRange = 1; actorDto.movePoint = 5; actorDto.playerId = 4; // 攻守 actorDto.attackPoint = 5; actorDto.defencePoint = 1; // 経験値 actorDto.exp = 0; actorDto.nextExp = 10; // HP actorDto.hitPoint = 15; actorDto.hitPointLimit = 15; actorDto.lv = 1; // 満腹度?精神力? actorDto.magicPoint = 100; actorDto.magicPointLimit = 100; ActorMapItem actorMapItem; actorMapItem.mapDataType = MapDataType::PLAYER; // 画面の中心(固定) actorMapItem.mapIndex = pointToIndex(Point(winSize.width/2, winSize.height/2)); actorMapItem.seqNo = 1; actorMapItem.moveDist = actorDto.movePoint; actorMapItem.attackDist = actorDto.attackRange; actorMapItem.moveDone = false; actorMapItem.attackDone = false; auto actorSprite = ActorSprite::createWithActorDto(actorDto); actorSprite->setPosition(indexToPoint(actorMapItem.mapIndex)); // 画面の中心 actorSprite->setActorMapItem(actorMapItem); actorSprite->runBottomAction(); // プレイヤーは画面中心にくるのでmapLayerに追加しない this->addChild(actorSprite, RogueScene::zActorBaseIndex, (RogueScene::kActorBaseTag + actorMapItem.seqNo)); // マップに追加 m_mapManager.addActor(actorSprite->getActorMapItem()); refreshStatus(); // プレイヤーの位置表示用(同じく1/8サイズ) auto miniMapActorLayer = LayerColor::create(Color4B::YELLOW); // タイルの1/8サイズ miniMapActorLayer->setContentSize(m_baseTileSize / 8); // 現在位置からPositionを取得して1/8にする miniMapActorLayer->setPosition(indexToPointNotTileSize(actorSprite->getActorMapItem()->mapIndex) / 8); // 移動時に更新できるようにplayerIdをtag管理 miniMapActorLayer->setTag(actorSprite->getTag()); // add miniMapLayer->addChild(miniMapActorLayer); // --------------------- // 敵キャラ生成 // --------------------- ActorSprite::ActorDto enemyDto; enemyDto.name = "スライム"; enemyDto.faceImgId = 0; enemyDto.imageResId = 1011; // 基本 enemyDto.attackRange = 1; // TODO: 未使用 enemyDto.movePoint = 10; // 索敵範囲 enemyDto.playerId = 901; // 攻守 enemyDto.attackPoint = 2; enemyDto.defencePoint = 0; // 経験値 enemyDto.exp = 0; enemyDto.nextExp = 10; // HP enemyDto.hitPoint = 10; enemyDto.hitPointLimit = 10; enemyDto.lv = 1; // 満腹度?精神力? enemyDto.magicPoint = 100; enemyDto.magicPointLimit = 100; MapIndex enemyMapIndex1 = {4, 4, MoveDirectionType::MOVE_DOWN}; tileSetEnemyActorMapItem(enemyDto, enemyMapIndex1); ActorSprite::ActorDto enemyDto2 = enemyDto; MapIndex enemyMapIndex2 = {14,12, MoveDirectionType::MOVE_DOWN}; tileSetEnemyActorMapItem(enemyDto2, enemyMapIndex2); ActorSprite::ActorDto enemyDto3 = enemyDto; MapIndex enemyMapIndex3 = {20,4, MoveDirectionType::MOVE_DOWN}; tileSetEnemyActorMapItem(enemyDto3, enemyMapIndex3); //------------------------- // アイテム配置 //------------------------- DropItemSprite::DropItemDto dropItemDto; dropItemDto.itemId = 1; dropItemDto.imageResId = 64; // imageId 10064 dropItemDto.name = "ポーション"; MapIndex mapIndex = {7, 5, MoveDirectionType::MOVE_NONE}; tileSetDropMapItem(dropItemDto, mapIndex); DropItemSprite::DropItemDto dropItemDto2; dropItemDto2.itemId = 2; dropItemDto2.imageResId = 168; // imageId 10168 dropItemDto2.name = "ぶどう"; MapIndex mapIndex2 = {10, 9, MoveDirectionType::MOVE_NONE}; tileSetDropMapItem(dropItemDto2, mapIndex2); // ------------------------------- // メニュー // ------------------------------- auto rect = Rect(0, 0, 300, 30); auto capRect = Rect(0, 0, 300, 30); auto pScale9Sprite1 = extension::Scale9Sprite::create("menu_button.png", rect, capRect); pScale9Sprite1->setContentSize(Size(40, 20)); pScale9Sprite1->setOpacity(192); auto pScale9Sprite2 = extension::Scale9Sprite::create("menu_button.png", rect, capRect); pScale9Sprite2->setContentSize(Size(40, 20)); pScale9Sprite2->setOpacity(128); auto pMenuItem1 = MenuItemSprite::create(pScale9Sprite1, pScale9Sprite2, [this](Object *pSender) { CCLOG("menuItem1が押された!"); showItemList(1); }); pMenuItem1->setColor(Color3B::GREEN); pMenuItem1->setPosition(Point(winSize.width - pMenuItem1->getContentSize().width / 2, pMenuItem1->getContentSize().height / 2)); auto pMenu = Menu::create(pMenuItem1, NULL); pMenu->setPosition(Point::ZERO); this->addChild(pMenu, RogueScene::zMenuIndex, RogueScene::kMenuTag); // --------------------------------- // プレイヤーの先行 changeGameStatus(GameStatus::PLAYER_TURN); return true; }
//! Write the footer std::string footer() const {return "</" + getTag() + ">";}
void PortraitWidget::setTag(const Common::UString &tag) { NWNWidget::setTag(tag); _portrait.setTag(getTag()); }
void MainScene::bottomFunction(Ref* pSender){ auto visibleSize = Director::getInstance()->getVisibleSize(); auto basicFunction = (MenuItemSprite*)pSender; int basicTag = basicFunction->getTag(); //TO DO....清除所有子节点 this->removeChildByTag(SHIELD_LAYER_TAG); this->removeChildByTag(HELLOWORLD_LAYER_TAG); this->removeChildByTag(MAIN_LAYER_TAG);//800 this->removeChildByTag(TEAMLIST_LAYER_TAG);//801 this->removeChildByTag(ZHENGZHAN_LAYER_TAG);//802 this->removeChildByTag(ACTIVITY_LAYER_TAG);//803 this->removeChildByTag(SHOP_LAYER_TAG);//804 this->removeChildByTag(ZHENFA_LAYER_TAG);//805 this->removeChildByTag(ZHENRONG_LAYER_TAG);//806 this->removeChildByTag(HEROINFO_LAYER_TAG);//810 if(basicTag!=11){ auto _shieldLayer = new ShieldLayer(); _shieldLayer->init(0); if(_shieldLayer){ this->addChild(_shieldLayer,3,SHIELD_LAYER_TAG); } } if (basicTag==11) { CCLOG("切换到Main页"); if (this->getChildByTag(MAIN_MENU_TAG)) { CCLOG("可以用"); } //((MenuItemSprite*)this->getChildByTag(MAIN_MENU_TAG)->getChildByTag(11))->selected(); auto _HelloWorldLayer = HelloWorldLayer::create(); if(_HelloWorldLayer){ //_HelloWorldLayer->setDelegator(_MainLayer); this->addChild(_HelloWorldLayer,1,HELLOWORLD_LAYER_TAG); } if(new_stage==3){//新手指导模式,进行剧情副本 //this->removeChildByTag(NEWPLAYER_LAYER_TAG); createNewPlayerLayer(10); } } if (basicTag==12) { CCLOG("切换到阵容页"); auto _ZhenRongLayer = ZhenRongLayer::create(); if(_ZhenRongLayer){ this->addChild(_ZhenRongLayer,4,ZHENRONG_LAYER_TAG); } if(new_stage>0){//新手指导模式 //this->removeChildByTag(NEWPLAYER_LAYER_TAG); if(new_stage==1) createNewPlayerLayer(4); } } if (basicTag==13) { CCLOG("切换到战争页"); auto _ZhengZhanLayer = ZhengZhanLayer::create(); if(_ZhengZhanLayer) this->addChild(_ZhengZhanLayer,4,ZHENGZHAN_LAYER_TAG); if(new_stage==0){//新手指导模式,进行剧情副本 createNewPlayerLayer(1); } else if(new_stage==2){//新手指导模式,进行剧情副本 createNewPlayerLayer(8); } else if(new_stage==3){//新手指导模式,进行剧情副本 //this->removeChildByTag(NEWPLAYER_LAYER_TAG); createNewPlayerLayer(8); } } if (basicTag==14) { CCLOG("切换到活动页"); cocosbuilder::NodeLoaderLibrary *ccNodeLoaderLibrary = cocosbuilder::NodeLoaderLibrary::newDefaultNodeLoaderLibrary(); cocosbuilder::CCBReader *ccbReader = new cocosbuilder::CCBReader(ccNodeLoaderLibrary); ccbReader->autorelease(); auto ccbCriticbg = ccbReader->readNodeGraphFromFile("ccb-buff/showCritic.ccbi", this); this->addChild(ccbCriticbg,5); ccbCriticbg->runAction(Sequence::create(DelayTime::create(0.5f),RemoveSelf::create(), NULL)); ccbCriticbg->setPosition(0,0); } if (basicTag==15) { CCLOG("切换到抽奖&集市页"); //auto layercol = LayerColor::create(Color4B(0,0,0,122), visibleSize.width, visibleSize.height); //layercol->setPosition(visibleSize.width/2,visibleSize.height/2); //this->addChild(layercol,8); cocosbuilder::NodeLoaderLibrary *ccNodeLoaderLibrary = cocosbuilder::NodeLoaderLibrary::newDefaultNodeLoaderLibrary(); cocosbuilder::CCBReader *ccbReader = new cocosbuilder::CCBReader(ccNodeLoaderLibrary); ccbReader->autorelease(); /*auto ccbCriticbg = ccbReader->readNodeGraphFromFile("skill_zhurigong_fly.ccbi", this); this->addChild(ccbCriticbg,6,5); ccbCriticbg->setPosition(visibleSize.width/4,visibleSize.height/2); auto seq = Sequence::create(MoveTo::create(0.3f, Point(visibleSize.width*3/4,visibleSize.height/2)),CallFuncN::create(CC_CALLBACK_1(MainScene::skill_hurt, this)),RemoveSelf::create(),NULL); seq->setTag(20); ccbCriticbg->runAction(seq); */ auto ccbCriticbg = ccbReader->readNodeGraphFromFile("ccb_fx/RuYunLong.ccbi", this); ccbCriticbg->setPosition(visibleSize.width/2,visibleSize.height/2); this->addChild(ccbCriticbg,5); /*auto bulletsp = Sprite::createWithSpriteFrameName("normal_bullet_02.png"); bulletsp->setPosition(visibleSize.width/4,visibleSize.height/2); this->addChild(bulletsp,3); auto seq = Sequence::create(MoveTo::create(0.3f, Point(visibleSize.width*3/4,visibleSize.height/2)),CallFuncN::create(CC_CALLBACK_1(MainScene::skill_hurt, this)),RemoveSelf::create(),NULL); bulletsp->runAction(seq); */ //schedule(schedule_selector(MainScene::skill_hurt),0.25f); } }
void peano::applications::poisson::vhhjacobi::configurations::JacobiBatchJobConfigurationForRegularGrid::parseSubtag( tarch::irr::io::IrrXMLReader* xmlReader ) { while( ( !(xmlReader->getNodeType()==tarch::irr::io::EXN_ELEMENT_END && xmlReader->getNodeName()==getTag()) ) && (xmlReader->read() ) ) { if ( xmlReader->getNodeType()==tarch::irr::io::EXN_ELEMENT ) { if ( xmlReader->getNodeName() == _logFilterConfiguration.getTag() ) { _logFilterConfiguration.parseSubtag(xmlReader); } } } }