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


C++ LTexture::loadFromFile方法代码示例

本文整理汇总了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;
}
开发者ID:Bfgeshka,项目名称:labyrinta,代码行数:35,代码来源:mmm.cpp

示例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;
    }
}
开发者ID:KarlRoe,项目名称:PixelChamp,代码行数:34,代码来源:sword.cpp

示例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;
}
开发者ID:stillcollating,项目名称:projects,代码行数:26,代码来源:13_alpha_blending.cpp

示例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;
}
开发者ID:Stephen-Lamb,项目名称:Work,代码行数:28,代码来源:39_tiling.cpp

示例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;
}
开发者ID:PetarValkov,项目名称:UbiShipsTask,代码行数:31,代码来源:CApp.cpp

示例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;
}
开发者ID:KarlRoe,项目名称:PixelChamp,代码行数:33,代码来源:gun.cpp

示例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;
}
开发者ID:nbudinov,项目名称:Game-Dev-Summer-2014,代码行数:49,代码来源:Main.cpp

示例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;
}
开发者ID:wedemalm,项目名称:lazyfoo,代码行数:15,代码来源:camera.cpp

示例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;
}
开发者ID:cvg256,项目名称:SDLTestGame,代码行数:48,代码来源:38_particle_engines.cpp

示例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;
}
开发者ID:kaprikawn,项目名称:sdl-starter,代码行数:33,代码来源:14.cpp

示例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;
}
开发者ID:mrhopehub,项目名称:SDL-game,代码行数:26,代码来源:main.cpp

示例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;
}
开发者ID:claranobre,项目名称:drifts,代码行数:34,代码来源:ClipRenderingColorKeyingAlphaBlending.cpp

示例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;
}
开发者ID:cvg256,项目名称:SDLTestGame,代码行数:31,代码来源:17_mouse_events.cpp

示例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;
}
开发者ID:kaprikawn,项目名称:sdl-starter,代码行数:18,代码来源:30.cpp

示例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;
}
开发者ID:sman13,项目名称:battleship,代码行数:57,代码来源:main.cpp


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