/** * @brief Updates this screen. */ void LanguageScreen::update() { if (finished) { set_next_screen(new TitleScreen(solarus)); } if (transition != NULL) { transition->update(); if (transition->is_finished()) { delete transition; transition = NULL; finished = true; } } }
/** * @brief Updates phase 3 of the title screen. */ void TitleScreen::update_phase_title() { transition_in->update(); transition_out->update(); uint32_t now = System::now(); if (now >= next_image_date) { if (counter == 0) { Sound::play("ok"); next_image_date = now + 1000; counter++; } else if (counter == 1) { next_image_date = now + 1000; counter++; } else { counter = 5 - counter; next_image_date = now + 500; } } while (now >= next_clouds_move_date) { clouds_position.add_x(1); clouds_position.add_y(-1); if (clouds_position.get_x() >= 535) { clouds_position.add_x(-535); } if (clouds_position.get_y() < 0) { clouds_position.add_y(299); } next_clouds_move_date = now + 50; } if (transition_out->is_finished()) { exit_phase_title(); set_next_screen(new SelectionMenu(solarus)); } }
/** * @brief Handles the transitions. * * This functions changes the map when needed and plays the * transitions between the two maps. This function is called * by the update() function. * Note that the two maps can actually be the same. */ void Game::update_transitions() { if (transition != NULL) { transition->update(); } // if the map has just changed, close the current map if any and play an out transition if (next_map != NULL && transition == NULL) { // the map has changed (i.e. set_current_map has been called) if (current_map == NULL) { // special case: no map was playing, so we don't have any out transition to do load_dungeon(); current_map = next_map; next_map = NULL; } else { // normal case: stop the control and play an out transition before leaving the current map transition = Transition::create(transition_style, Transition::OUT, this); transition->start(); } } Rectangle previous_map_location = current_map->get_location(); // if a transition was playing and has just been finished if (transition != NULL && transition->is_finished()) { Transition::Direction transition_direction = transition->get_direction(); bool needs_previous_surface = transition->needs_previous_surface(); delete transition; transition = NULL; if (reseting) { current_map->unload(); set_next_screen(new TitleScreen(solarus)); } else if (restarting) { current_map->unload(); set_next_screen(new Game(solarus, savegame)); } else if (transition_direction == Transition::OUT) { if (next_map == current_map) { // same map hero->place_on_destination_point(*current_map, previous_map_location); transition = Transition::create(transition_style, Transition::IN, this); transition->start(); next_map = NULL; } else { // change the map current_map->leave(); // special treatments for an inside/outside transition if ((current_map->is_in_outside_world() && !next_map->is_in_outside_world()) || (!current_map->is_in_outside_world() && next_map->is_in_outside_world())) { // reset the crystal switch blocks crystal_switch_state = false; // save the location savegame.set_integer(Savegame::STARTING_MAP, next_map->get_id()); savegame.set_string(Savegame::STARTING_POINT, next_map->get_destination_point_name()); } // before closing the map, draw it on a backup surface for transition effects // that want to display both maps at the same time if (needs_previous_surface) { previous_map_surface = new Surface(320, 240); current_map->display(); current_map->get_visible_surface()->blit(previous_map_surface); } // set the next map load_dungeon(); current_map->unload(); delete current_map; current_map = next_map; next_map = NULL; } } else { current_map->notify_opening_transition_finished(); if (previous_map_surface != NULL) { delete previous_map_surface; previous_map_surface = NULL; } } } // if a map has just been set as the current map, start it and play the in transition if (!current_map->is_started()) { transition = Transition::create(transition_style, Transition::IN, this); if (previous_map_surface != NULL) { // some transition effects need to display both maps simultaneously transition->set_previous_surface(previous_map_surface); } hero->place_on_destination_point(*current_map, previous_map_location); transition->start(); current_map->start(); } }