当前位置: 首页>>代码示例>>C++>>正文


C++ game_display::delay方法代码示例

本文整理汇总了C++中game_display::delay方法的典型用法代码示例。如果您正苦于以下问题:C++ game_display::delay方法的具体用法?C++ game_display::delay怎么用?C++ game_display::delay使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在game_display的用法示例。


在下文中一共展示了game_display::delay方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: fade_logo

/**
 *  Fade-in the wesnoth-logo.
 *
 *  Animation-effect: scroll-in from right. \n
 *  Used only once, after the game is started.
 *
 *  @param	screen	surface to operate on
 *  @param	xpos	x-position of logo
 *  @param	ypos	y-position of logo
 *
 *  @return		Result of running the routine
 *  @retval true	operation finished (successful or not)
 *  @retval false	operation failed (because modeChanged), need to retry
 */
static bool fade_logo(game_display& screen, int xpos, int ypos)
{
	const surface logo(image::get_image(game_config::game_logo));
	if(logo == NULL) {
		ERR_DP << "Could not find game logo\n";
		return true;
	}

	surface const fb = screen.video().getSurface();

	if(fb == NULL || xpos < 0 || ypos < 0 || xpos + logo->w > fb->w || ypos + logo->h > fb->h) {
		return true;
	}

	// Only once, when the game is first started, the logo fades in unless
	// it was disabled in adv. preferences
	static bool faded_in = !preferences::startup_effect();
//	static bool faded_in = true;	// for faster startup: mark logo as 'has already faded in'

	CKey key;
	bool last_button = key[SDLK_ESCAPE] || key[SDLK_SPACE];

	LOG_DP << "fading logo in....\n";
	LOG_DP << "logo size: " << logo->w << "," << logo->h << "\n";

	for(int x = 0; x != logo->w; ++x) {
		SDL_Rect srcrect = {x,0,1,logo->h};
		SDL_Rect dstrect = {xpos+x,ypos,1,logo->h};
		SDL_BlitSurface(logo,&srcrect,fb,&dstrect);

		update_rect(dstrect);

		if(!faded_in && (x%5) == 0) {

			const bool new_button = key[SDLK_ESCAPE] || key[SDLK_SPACE] ||
									key[SDLK_RETURN] || key[SDLK_KP_ENTER] ;
			if(new_button && !last_button) {
				faded_in = true;
			}

			last_button = new_button;

			screen.update_display();
			screen.delay(10);

			events::pump();
			if(screen.video().modeChanged()) {
				faded_in = true;
				return false;
			}
		}

	}

	LOG_DP << "logo faded in\n";

	faded_in = true;
	return true;
}
开发者ID:oys0317,项目名称:opensanguo,代码行数:73,代码来源:titlescreen.cpp

示例2: show_title


//.........这里部分代码省略.........
	
	
	memory_stats("At titlescreen");
	
	// Initialize OpenFeint now
	of_init();

	
	for(;;) {
		events::pump();
		for(size_t b = 0; b != buttons.size(); ++b) {
			if(buttons[b].pressed()) {
				free_title();
				return static_cast<TITLE_RESULT>(b + NEW_CAMPAIGN);
			}
		}

/*		if(previous_tip_button.pressed()) {
			next_tip_of_day(tips_of_day, true);
			draw_tip_of_day(screen, tips_of_day, gui::dialog_frame::titlescreen_style,
						&previous_tip_button, &next_tip_button, &help_tip_button, &main_dialog_area, tip_of_day_restorer);
		}
		if(next_tip_button.pressed()) {
			next_tip_of_day(tips_of_day, false);
			draw_tip_of_day(screen, tips_of_day, gui::dialog_frame::titlescreen_style,
						&previous_tip_button, &next_tip_button, &help_tip_button, &main_dialog_area, tip_of_day_restorer);
		}
*/
//		if(help_tip_button.pressed()) {
//			return SHOW_HELP;
//		}
//		if(beg_button.pressed()) {
//			return BEG_FOR_UPLOAD;
//		}
		if (key[SDLK_UP]) {
			if (!key_processed) {
				buttons[keyboard_button].set_active(false);
				if (keyboard_button == 0) {
					keyboard_button = nbuttons - 1;
				} else {
					keyboard_button--;
				}
				key_processed = true;
				buttons[keyboard_button].set_active(true);
			}
		} else if (key[SDLK_DOWN]) {
			if (!key_processed) {
				buttons[keyboard_button].set_active(false);
				if (keyboard_button > nbuttons - 1) {
					keyboard_button = 0;
				} else {
					keyboard_button++;
				}
				key_processed = true;
				buttons[keyboard_button].set_active(true);
			}
		} else {
			key_processed = false;
		}

		events::raise_process_event();
		
		
		// KP: redraw
		draw_background(screen);
		main_frame.draw_background();
		main_frame.draw_border();
		events::raise_draw_event();
		//blit_surface(480-logo_surface.get()->w, 0, logo_surface);
#ifdef __IPAD__
		blit_surface(-10, 0, logo_surface);
#else
		blit_surface(-15, -10, logo_surface);
#endif
		
		screen.flip();

//		if (key[SDLK_ESCAPE] && !ts_handler.get_esc_ignore())
//			return QUIT_GAME;
		if (key[SDLK_F5])
			return RELOAD_GAME_DATA;

		if (key[SDLK_RETURN] && keyboard_button < nbuttons) {
			return static_cast<TITLE_RESULT>(keyboard_button + NEW_CAMPAIGN);
		}



		// If the resolution has changed due to the user resizing the screen,
		// or from changing between windowed and fullscreen:
		if(screen.video().modeChanged()) {
			return REDRAW_BACKGROUND;
		}
		
		screen.delay(10);
	}

	free_title();
	return REDRAW_BACKGROUND;
}
开发者ID:dodikk,项目名称:iWesnoth,代码行数:101,代码来源:titlescreen.cpp


注:本文中的game_display::delay方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。