本文整理汇总了C++中LTexture::setAlpha方法的典型用法代码示例。如果您正苦于以下问题:C++ LTexture::setAlpha方法的具体用法?C++ LTexture::setAlpha怎么用?C++ LTexture::setAlpha使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LTexture
的用法示例。
在下文中一共展示了LTexture::setAlpha方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadMedia
bool loadMedia()
{
//Loading success flag
bool success = true;
//Load dot texture
if( !gDotTexture.loadFromFile( "assets/38_particle_engines/dot.bmp" ) )
{
printf( "Failed to load dot texture!\n" );
success = false;
}
//Load red texture
if( !gRedTexture.loadFromFile( "assets/38_particle_engines/red.bmp" ) )
{
printf( "Failed to load red texture!\n" );
success = false;
}
//Load green texture
if( !gGreenTexture.loadFromFile( "assets/38_particle_engines/green.bmp" ) )
{
printf( "Failed to load green texture!\n" );
success = false;
}
//Load blue texture
if( !gBlueTexture.loadFromFile( "assets/38_particle_engines/blue.bmp" ) )
{
printf( "Failed to load blue texture!\n" );
success = false;
}
//Load shimmer texture
if( !gShimmerTexture.loadFromFile( "assets/38_particle_engines/shimmer.bmp" ) )
{
printf( "Failed to load shimmer texture!\n" );
success = false;
}
//Set texture transparency
gRedTexture.setAlpha( 192 );
gGreenTexture.setAlpha( 192 );
gBlueTexture.setAlpha( 192 );
gShimmerTexture.setAlpha( 192 );
return success;
}
示例2: render
void Scoreboard::render( SDL_Renderer* gRenderer, TTF_Font* gFont, LTexture gTextTexture ) {
string s = std::to_string( static_cast<long long>( score ) );
s = string( 10 - s.size(), ' ' ) + s;
string text = "Score: " + s;
gTextTexture.loadFromRenderedText( text, textColor );
gTextTexture.setBlendMode( SDL_BLENDMODE_BLEND );
gTextTexture.setAlpha( 150 );
gTextTexture.render( xPos, yPos, gRenderer );
}
示例3: if
int
main(int argc, char *argv[])
{
int quit = 0;
/* event handler */
SDL_Event event;
/* modulation components */
Uint8 alpha = 255;
/* starts up SDL and create window */
if (init_sdl() == -1) {
fprintf(stderr, "Failed to initialize SDL!\n");
return -1;
}
/* load media */
if (load_media() == -1) {
fprintf(stderr, "Failed to load media!\n");
return -2;
}
/* main loop */
while (quit == 0) {
/* handle events on queue */
while (SDL_PollEvent(&event) != 0) {
/* users request quit */
if (event.type == SDL_QUIT)
quit = 1;
/* on key press change alpha values */
else if (event.type == SDL_KEYDOWN) {
/* increase alpha on w */
if (event.key.keysym.sym == SDLK_w) {
if (alpha + 32 > 255)
alpha = 255;
else
alpha += 32;
/* decrease alpha on s */
} else if (event.key.keysym.sym == SDLK_s) {
if (alpha - 32 < 0)
alpha = 0;
else
alpha -= 32;
}
}
}
/* clear screen */
SDL_SetRenderDrawColor(gRenderer, 0xFF, 0xFF, 0xFF, 0xFF);
SDL_RenderClear(gRenderer);
/* render background */
gBackgroundTexture.render(0, 0);
/* render front blended */
gModulatedTexture.setAlpha(alpha);
gModulatedTexture.render(0, 0);
/* update screen */
SDL_RenderPresent(gRenderer);
}
/* free resources and close */
close_sdl();
return 0;
}
示例4: main
int main( int argc, char* args[] )
{
//Start up SDL and create window
if( !init() )
{
printf( "Failed to initialize!\n" );
}
else
{
//Load media
if( !loadMedia() )
{
printf( "Failed to load media!\n" );
}
else
{
//Main loop flag
bool quit = false;
//Event handler
SDL_Event e;
//Modulation component
Uint8 a = 255;
//While application is running
while( !quit )
{
//Handle events on queue
while( SDL_PollEvent( &e ) != 0 )
{
//User requests quit
if( e.type == SDL_QUIT )
{
quit = true;
}
//Handle key presses
else if( e.type == SDL_KEYDOWN )
{
//Increase alpha on w
if( e.key.keysym.sym == SDLK_w )
{
//Cap if over 255
if( a + 32 > 255 )
{
a = 255;
}
//Increment otherwise
else
{
a += 32;
}
}
//Decrease alpha on s
else if( e.key.keysym.sym == SDLK_s )
{
//Cap if below 0
if( a - 32 < 0 )
{
a = 0;
}
//Decrement otherwise
else
{
a -= 32;
}
}
}
}
//Clear screen
SDL_SetRenderDrawColor( gRenderer, 0xFF, 0xFF, 0xFF, 0xFF );
SDL_RenderClear( gRenderer );
//Render background
gBackgroundTexture.render( 0, 0 );
//Render front blended
gModulatedTexture.setAlpha( a );
gModulatedTexture.render( 0, 0 );
//Update screen
SDL_RenderPresent( gRenderer );
}
}
}
//Free resources and close SDL
close();
return 0;
}