本文整理汇总了C++中Sector::activate方法的典型用法代码示例。如果您正苦于以下问题:C++ Sector::activate方法的具体用法?C++ Sector::activate怎么用?C++ Sector::activate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sector
的用法示例。
在下文中一共展示了Sector::activate方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void
TitleScreen::make_tux_jump()
{
static bool jumpWasReleased = true;
Sector* sector = titlesession->get_current_sector();
Player* tux = sector->player;
controller->update();
controller->press(Controller::RIGHT);
// Check if we should press the jump button
Rectf lookahead = tux->get_bbox();
lookahead.p2.x += 96;
bool pathBlocked = !sector->is_free_of_statics(lookahead);
if ((pathBlocked && jumpWasReleased) || !tux->on_ground()) {
controller->press(Controller::JUMP);
jumpWasReleased = false;
} else {
jumpWasReleased = true;
}
// Wrap around at the end of the level back to the beginning
if(sector->get_width() - 320 < tux->get_pos().x) {
sector->activate("main");
sector->camera->reset(tux->get_pos());
}
}
示例2: if
void
GameSession::update(float elapsed_time)
{
// Set active flag
if(!active)
{
active = true;
}
// handle controller
if(InputManager::current()->get_controller()->pressed(Controller::ESCAPE) ||
InputManager::current()->get_controller()->pressed(Controller::START))
{
on_escape_press();
}
if(InputManager::current()->get_controller()->pressed(Controller::CHEAT_MENU) &&
g_config->developer_mode)
{
if (!MenuManager::instance().is_active())
{
game_pause = true;
MenuManager::instance().set_menu(MenuStorage::CHEAT_MENU);
}
}
process_events();
// Unpause the game if the menu has been closed
if (game_pause && !MenuManager::instance().is_active()) {
ScreenManager::current()->set_speed(speed_before_pause);
SoundManager::current()->resume_music();
SoundManager::current()->resume_sounds();
currentsector->play_looping_sounds();
game_pause = false;
}
check_end_conditions();
// respawning in new sector?
if(!newsector.empty() && !newspawnpoint.empty()) {
Sector* sector = level->get_sector(newsector);
if(sector == 0) {
log_warning << "Sector '" << newsector << "' not found" << std::endl;
sector = level->get_sector("main");
}
currentsector->stop_looping_sounds();
sector->activate(newspawnpoint);
sector->play_music(LEVEL_MUSIC);
currentsector = sector;
currentsector->play_looping_sounds();
//Keep persistent across sectors
if(edit_mode)
currentsector->get_players()[0]->set_edit_mode(edit_mode);
newsector = "";
newspawnpoint = "";
}
// Update the world state and all objects in the world
if(!game_pause) {
// Update the world
if (!end_sequence) {
play_time += elapsed_time; //TODO: make sure we don't count cutscene time
level->stats.time = play_time;
currentsector->update(elapsed_time);
} else {
if (!end_sequence->is_tux_stopped()) {
currentsector->update(elapsed_time);
} else {
end_sequence->update(elapsed_time);
}
}
}
if(currentsector == NULL)
return;
// update sounds
if (currentsector->camera) SoundManager::current()->set_listener_position(currentsector->camera->get_center());
/* Handle music: */
if (end_sequence)
return;
if(currentsector->player->invincible_timer.started()) {
if(currentsector->player->invincible_timer.get_timeleft() <=
TUX_INVINCIBLE_TIME_WARNING) {
currentsector->play_music(HERRING_WARNING_MUSIC);
} else {
currentsector->play_music(HERRING_MUSIC);
}
} else if(currentsector->get_music_type() != LEVEL_MUSIC) {
currentsector->play_music(LEVEL_MUSIC);
}
if (reset_button) {
reset_button = false;
reset_level();
restart_level();
}
}
示例3: if
void
GameSession::update(float elapsed_time)
{
// handle controller
if(g_jk_controller->get_main_controller()->pressed(Controller::PAUSE_MENU))
on_escape_press();
process_events();
process_menu();
// Unpause the game if the menu has been closed
if (game_pause && !MenuManager::current()) {
g_screen_manager->set_speed(speed_before_pause);
game_pause = false;
}
check_end_conditions();
// respawning in new sector?
if(newsector != "" && newspawnpoint != "") {
Sector* sector = level->get_sector(newsector);
if(sector == 0) {
log_warning << "Sector '" << newsector << "' not found" << std::endl;
sector = level->get_sector("main");
}
sector->activate(newspawnpoint);
sector->play_music(LEVEL_MUSIC);
currentsector = sector;
//Keep persistent across sectors
if(edit_mode)
currentsector->get_players()[0]->set_edit_mode(edit_mode);
newsector = "";
newspawnpoint = "";
}
// Update the world state and all objects in the world
if(!game_pause) {
// Update the world
if (!end_sequence) {
play_time += elapsed_time; //TODO: make sure we don't count cutscene time
level->stats.time = play_time;
currentsector->update(elapsed_time);
} else {
if (!end_sequence->is_tux_stopped()) {
currentsector->update(elapsed_time);
} else {
end_sequence->update(elapsed_time);
}
}
}
// update sounds
if (currentsector && currentsector->camera) sound_manager->set_listener_position(currentsector->camera->get_center());
/* Handle music: */
if (end_sequence)
return;
if(currentsector->player->invincible_timer.started()) {
if(currentsector->player->invincible_timer.get_timeleft() <=
TUX_INVINCIBLE_TIME_WARNING) {
currentsector->play_music(HERRING_WARNING_MUSIC);
} else {
currentsector->play_music(HERRING_MUSIC);
}
} else if(currentsector->get_music_type() != LEVEL_MUSIC) {
currentsector->play_music(LEVEL_MUSIC);
}
}