本文整理汇总了C++中LTexture::loadFromFile方法的典型用法代码示例。如果您正苦于以下问题:C++ LTexture::loadFromFile方法的具体用法?C++ LTexture::loadFromFile怎么用?C++ LTexture::loadFromFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LTexture
的用法示例。
在下文中一共展示了LTexture::loadFromFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadMedia
bool loadMedia()
{
//Loading success flag
bool success = true;
//Load sprites
{if( !gButtonSpriteSheetTexture.loadFromFile( "res/menu/button.png" ) )
{
printf( "Failed to load button sprite texture!\n" );
success = false;
}
else
{
//Set sprites
for( int i = 0; i < 4; ++i )
{
gSpriteClips[ i ].x = 0;
gSpriteClips[ i ].y = i * 200;
gSpriteClips[ i ].w = BUTTON_WIDTH;
gSpriteClips[ i ].h = BUTTON_HEIGHT;
}
//Set buttons in corners
gButtons[ 0 ].setPosition( 127, 150 );
}
}
if( !gBackgroundTexture.loadFromFile( "res/menu/new_background.png" ) )
{
printf( "Failed to load background texture image!\n" );
success = false;
}
return success;
}
示例2: if
SDL_Rect sword :: get_position(Dot myDot, Setup foo)
{
if(look_up)
{
box.x = myDot.box.x;
box.y = (myDot.box.y - le) + properHeight;
weaponsT.loadFromFile( "first_test12.bmp" );
}
else if(look_down && !myDot.is_onGround()) ///very much so temp--- this should be its own move, once i get moves sorted :D
{
box.x = myDot.box.x;
box.y = myDot.box.y + myDot.box.h;
weaponsT.loadFromFile( "first_test11.bmp" );
}
else
{
if(!direction)
{
box.x = myDot.box.x + trueWidth;
weaponsT.loadFromFile( "first_test10.bmp" );
}
else
{
box.x = (myDot.box.x - 128) + (128 - trueWidth);
weaponsT.loadFromFile( "first_test9.bmp" );
}
box.y = myDot.box.y + trueHeight/2;
return box;
}
}
示例3: loadMedia
bool loadMedia()
{
//Loading success flag
bool success = true;
//Load front alpha texture
if( !gModulatedTexture.loadFromFile( "13_alpha_blending/fadeout.png" ) )
{
printf( "Failed to load front texture!\n" );
success = false;
}
else
{
//Set standard alpha blending
gModulatedTexture.setBlendMode( SDL_BLENDMODE_BLEND );
}
//Load background texture
if( !gBackgroundTexture.loadFromFile( "13_alpha_blending/fadein.png" ) )
{
printf( "Failed to load background texture!\n" );
success = false;
}
return success;
}
示例4: loadMedia
bool loadMedia( Tile* tiles[] )
{
//Loading success flag
bool success = true;
//Load dot texture
if( !gDotTexture.loadFromFile( "39_tiling/dot.bmp" ) )
{
printf( "Failed to load dot texture!\n" );
success = false;
}
//Load tile texture
if( !gTileTexture.loadFromFile( "39_tiling/tiles.png" ) )
{
printf( "Failed to load tile set texture!\n" );
success = false;
}
//Load tile map
if( !setTiles( tiles ) )
{
printf( "Failed to load tile set!\n" );
success = false;
}
return success;
}
示例5: loadMedia
bool loadMedia()
{
//Loading success flag
bool success = true;
if (!gDotTexture.loadFromFile( "gosho.png" ))
{
printf( "Failed to load ship texture!\n");
success = false;
}
if( !gEnemyTexture.loadFromFile( "enemy.png" ) )
{
printf( "Failed to load arrow texture!\n" );
success = false;
}
if( !gBulletTexture.loadFromFile( "bullet.png" ) )
{
printf( "Failed to load arrow texture!\n" );
success = false;
}
if( !gBGTexture.loadFromFile( "background.png" ) )
{
printf( "Failed to load arrow texture!\n" );
success = false;
}
return success;
}
示例6: if
SDL_Rect gun :: get_position(Dot myDot, Setup foo)
{
if(look_up)
{
box.x = myDot.box.x;
box.y = myDot.box.y;
weapons2T.loadFromFile( "first_test16.bmp" );
}
else if(look_down && !myDot.is_onGround()) ///very much so temp--- this should be its own move, once i get moves sorted :D
{
box.x = myDot.box.x;
box.y = myDot.box.y + (myDot.box.h - speed);
weapons2T.loadFromFile( "first_test15.bmp" );
}
else
{
if(!direction)
{
box.x = myDot.box.x + (trueWidth - speed);
weapons2T.loadFromFile( "first_test14.bmp" );
}
else
{
box.x = (myDot.box.x - 128) + (128 - trueWidth);
weapons2T.loadFromFile( "first_test13.bmp" );
}
box.y = myDot.box.y + trueHeight/2;
}
return box;
}
示例7: loadMedia
bool loadMedia()
{
//Loading success flag
bool success = true;
gFont = TTF_OpenFont( "images/lazy.ttf", 22 );
if( gFont == NULL )
{
printf( "Failed to load lazy font! SDL_ttf Error: %s\n", TTF_GetError() );
success = false;
}
else
{
//Render text
SDL_Color textColor = { 0xFF, 0xFF, 0 };
if( !gPlayerLifesTexture.loadFromRenderedText( " Lifes: ", textColor, gRenderer, gFont ) )
{
printf( "Failed to render text texture!\n" );
success = false;
}
}
if( !gPlayerTexture.loadFromFile( "images/player.bmp", gRenderer ) )
{
printf( "Failed to load dot texture!\n" );
success = false;
}
if( !gProjTexture.loadFromFile( "images/projectile.bmp", gRenderer ) )
{
printf( "Failed to load dot texture!\n" );
success = false;
}
if( !gShipTexture.loadFromFile( "images/ship.bmp", gRenderer ) )
{
printf( "Failed to load dot texture!\n" );
success = false;
}
if( !gLoseScreen.loadFromFile( "images/losescreen.png", gRenderer ) )
{
printf( "Failed to load LoSE screen texture!\n" );
success = false;
}
return success;
}
示例8: loadMedia
bool loadMedia() {
//Loading success flag
bool success = true;
if(!g_dotTexture.loadFromFile("dot.bmp")) {
printf("Failed to load dot texture!\n");
success = false;
}
if(!g_bgTexture.loadFromFile("bg.png")) {
printf("Failed to load bg texture!\n");
success = false;
}
return success;
}
示例9: 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;
}
示例10: loadMedia
bool loadMedia() {
//Loading success flag
bool success = true;
//Load sprite sheet texture
if( !gSpriteSheetTexture.loadFromFile( "14_animated_sprites_and_vsync/foo.png" ) ) {
printf( "Failed to load walking animation texture!\n" );
success = false;
} else {
//Set sprite clips
gSpriteClips[ 0 ].x = 0;
gSpriteClips[ 0 ].y = 0;
gSpriteClips[ 0 ].w = 64;
gSpriteClips[ 0 ].h = 205;
gSpriteClips[ 1 ].x = 64;
gSpriteClips[ 1 ].y = 0;
gSpriteClips[ 1 ].w = 64;
gSpriteClips[ 1 ].h = 205;
gSpriteClips[ 2 ].x = 128;
gSpriteClips[ 2 ].y = 0;
gSpriteClips[ 2 ].w = 64;
gSpriteClips[ 2 ].h = 205;
gSpriteClips[ 3 ].x = 196;
gSpriteClips[ 3 ].y = 0;
gSpriteClips[ 3 ].w = 64;
gSpriteClips[ 3 ].h = 205;
}
return success;
}
示例11: loadMedia
bool loadMedia()
{
//Loading success flag
bool success = true;
//Load sprite sheet texture
if( !gSpriteSheetTexture.loadFromFile( "11_clip_rendering_and_sprite_sheets/game.png" ) )
{
printf( "Failed to load sprite sheet texture!\n" );
success = false;
}
else
{
//初始化矩形
for(int i = 0; i <= 2; i++)
for(int j = 0; j <= 2; j++)
{
gSpriteClips[i * 3 + j].x = j * 250;
gSpriteClips[i * 3 + j].y = i * 200;
gSpriteClips[i * 3 + j].w = 250;
gSpriteClips[i * 3 + j].h = 200;
}
}
return success;
}
示例12: loadMedia
bool loadMedia()
{
bool success = true;
if( !gSquare.loadFromFile( "Sprites/Animation.png" ) )
{
cout << "Falha ao carregar a sprite principal." << endl;
success = false;
}
else
{
gSpriteClips[ANIMATION1].x = 0;
gSpriteClips[ANIMATION1].y = 0;
gSpriteClips[ANIMATION1].w = 250;
gSpriteClips[ANIMATION1].h = 300;
gSpriteClips[ANIMATION2].x = 250;
gSpriteClips[ANIMATION2].y = 0;
gSpriteClips[ANIMATION2].w = 250;
gSpriteClips[ANIMATION2].h = 300;
gSpriteClips[ANIMATION3].x = 500;
gSpriteClips[ANIMATION3].y = 0;
gSpriteClips[ANIMATION3].w = 250;
gSpriteClips[ANIMATION3].h = 300;
gSpriteClips[ANIMATION4].x = 750;
gSpriteClips[ANIMATION4].y = 0;
gSpriteClips[ANIMATION4].w = 250;
gSpriteClips[ANIMATION4].h = 300;
}
return success;
}
示例13: loadMedia
bool loadMedia()
{
//Loading success flag
bool success = true;
//Load sprites
if( !gButtonSpriteSheetTexture.loadFromFile( "assets/17_mouse_events/button.png" ) )
{
printf( "Failed to load button sprite texture!\n" );
success = false;
}
else
{
//Set sprites
for( int i = 0; i < BUTTON_SPRITE_TOTAL; ++i )
{
gSpriteClips[ i ].x = 0;
gSpriteClips[ i ].y = i * 200;
gSpriteClips[ i ].w = BUTTON_WIDTH;
gSpriteClips[ i ].h = BUTTON_HEIGHT;
}
//Set buttons in corners
gButtons[ 0 ].setPosition( 0, 0 );
gButtons[ 1 ].setPosition( SCREEN_WIDTH - BUTTON_WIDTH, 0 );
gButtons[ 2 ].setPosition( 0, SCREEN_HEIGHT - BUTTON_HEIGHT );
gButtons[ 3 ].setPosition( SCREEN_WIDTH - BUTTON_WIDTH, SCREEN_HEIGHT - BUTTON_HEIGHT );
}
return success;
}
示例14: loadMedia
bool loadMedia() {
//Loading success flag
bool success = true;
//Load dot texture
if( !gDotTexture.loadFromFile( "30_scrolling/dot.bmp" ) ) {
printf( "Failed to load dot texture!\n" );
success = false;
}
//Load background texture
if( !gBGTexture.loadFromFile( "30_scrolling/bg.png" ) ) {
printf( "Failed to load background texture!\n" );
success = false;
}
return success;
}
示例15: IntroRender
bool IntroRender (int x, int y)
{
//Event handler
SDL_Event e;
LTexture texture;
std::string counter="";
for (int i=0; i<1502; i+=2)
{
//Handle events on queue
while( SDL_PollEvent( &e ) != 0 )
{
//Clear screen
SDL_SetRenderDrawColor( gRenderer, 0, 0, 0, 0 );
SDL_RenderClear( gRenderer );
//User requests quit
if( e.type == SDL_QUIT )
{
return false;
}
}
bool quit=false;
counter+="IntroPics/Intro";
counter+=IntToString(i+1);
counter+=".jpg";
Intro [i]=texture.loadFromFile( counter.c_str(),gScreenRect.w, gScreenRect.h);
gSplashTexture.render(x, y,Intro[i],IntroW, IntroH);
//Update screen
SDL_RenderPresent( gRenderer );
if (Intro [i]!=NULL)
{
SDL_DestroyTexture( Intro [i] );
Intro [i] = NULL;
};
printf(counter.c_str());
counter="";
SDL_Delay(10);
}
// //Render splash
// for (int i=0 ; i<1410; i++)
//
// {
// if (Intro [i]!=NULL)
//
// {
// SDL_DestroyTexture( Intro [i] );
// Intro [i] = NULL;
// };
// if (i<910)
// Intro [i+500]=texture.loadFromFile( counter.c_str(),gScreenRect.w, gScreenRect.h);
// }
return true;
}