本文整理汇总了C++中sf::Sprite::SetImage方法的典型用法代码示例。如果您正苦于以下问题:C++ Sprite::SetImage方法的具体用法?C++ Sprite::SetImage怎么用?C++ Sprite::SetImage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sf::Sprite
的用法示例。
在下文中一共展示了Sprite::SetImage方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
void init(){
_backgroundImage.LoadFromFile("assets/wood-puzzle-floor.png");
_backgroundSprite.SetImage(_backgroundImage);
_robotImage.LoadFromFile("assets/roomba.png");
_robotSprite.SetImage(_robotImage);
_robotSprite.SetCenter(_robotSprite.GetSize().x/2, _robotSprite.GetSize().y/2);
_fakeRobotSprite.SetImage(_robotImage);
_fakeRobotSprite.SetCenter(_fakeRobotSprite.GetSize().x/2, _fakeRobotSprite.GetSize().y/2);
_fakeRobotSprite.SetColor(sf::Color(100,100,255));
_landmarkImage.LoadFromFile("assets/landmark.png");
_landmarkSprite.SetImage(_landmarkImage);
_landmarkSprite.SetCenter(_landmarkSprite.GetSize().x/2, _landmarkSprite.GetSize().y/2);
_rangeImage.LoadFromFile("assets/range.png");
_rangeSprite.SetImage(_rangeImage);
original_range_sprite_size_x = _rangeSprite.GetSize().x;
original_range_sprite_size_y = _rangeSprite.GetSize().y;
updateRangeSpriteScale();
_rangeSprite.SetCenter((original_range_sprite_size_x/2), (original_range_sprite_size_y/2));
_window.Create(sf::VideoMode(window_width,window_height,32), "Bearing simulator");
move_amount = 0;
rotation_amount = 0;
time_to_capture = false;
walk = 0;
rotation = 0;
}
示例2: main
int main()
{
img_r.LoadFromFile("..\\Imagenes\\rcircle.png");
img_b.LoadFromFile("..\\Imagenes\\bcircle.png");
sprite_b.SetImage(img_b);
sprite_r.SetImage(img_r);
sf::RenderWindow App(sf::VideoMode(800,600,32),"ventana");
const sf::Input& in = App.GetInput();
sprite_b.Scale(sprite_r.GetSize().x/sprite_b.GetSize().x,sprite_r.GetSize().y/sprite_b.GetSize().y);
while(App.IsOpened())
{
while(App.GetEvent(Event))
{
if(Event.Type == sf::Event::Closed)
App.Close();
if(Event.Type == sf::Event::MouseMoved){
// cursor.SetPosition(Event.MouseMove.X,Event.MouseMove.Y);
}
}
if(in.IsKeyDown(sf::Key::Escape))
App.Close();
//cursor.SetPosition(in.GetMouseX(),in.GetMouseY());
App.Clear();
sprite_r.SetPosition(0,0);
App.Draw(sprite_r);
sprite_r.SetPosition(App.GetWidth()-img_r.GetWidth(),0);
App.Draw(sprite_r);
sprite_r.SetPosition(0,App.GetHeight()-img_r.GetHeight());
App.Draw(sprite_r);
sprite_r.SetPosition(App.GetWidth()-img_r.GetWidth(),App.GetHeight()-img_r.GetHeight());
App.Draw(sprite_r);
sprite_b.SetPosition((App.GetWidth()-sprite_b.GetSize().x)/2,(App.GetHeight()-sprite_b.GetSize().y)/2);
App.Draw(sprite_b);
App.Display();
}
return 0;
}
示例3: load_image
void _Log::load_image(){
if( image_loaded == false && image_path.length() != 0 ) {
Sprite.SetImage( VNImageManager.get_image( image_path ) );
Sprite.SetY( WINDOW_HEIGHT - Sprite.GetSize().y );
switch( align ){
case 1:
Sprite.SetX( 0.f );
break;
case 2:
Sprite.SetX( 100.f );
break;
case 3:
Sprite.SetX( WINDOW_WIDTH/2 - Sprite.GetSize().x /2 );
break;
case 4:
Sprite.SetX( WINDOW_WIDTH - 100.f - Sprite.GetSize().x );
break;
case 5:
Sprite.SetX( WINDOW_WIDTH - Sprite.GetSize().x );
break;
}
image_loaded = true;
}
}
示例4: GetSpriteTiles
void ImageManager::GetSpriteTiles(sf::Sprite &sprite, int tile, int modeSelection)
{
if(modeSelection == MAP)
{
sprite.SetImage(m_tilsetMap);
sprite.SetSubRect(sf::IntRect(TILE_WIDTH*tile, 0, TILE_WIDTH*(tile+1), TILE_HEIGHT));
}
else if(modeSelection == WORLD)
{
sprite.SetImage(m_tilsetWorld);
sprite.SetSubRect(sf::IntRect(TILE_WIDTH*tile, 0, TILE_WIDTH*(tile+1), TILE_HEIGHT));
}
else
std::cerr << "erreur fonction ImageManager.GetSpriteTiles appelée avec modeSelection != MAP et modeSelection != WORLD" << std::endl;
}
示例5: GetSpriteEnemy
void ImageManager::GetSpriteEnemy(sf::Sprite &sprite, int whichEnemy)
{
if(whichEnemy == ENEMY1)
{
sprite.SetImage(m_enemy1);
sprite.SetSubRect(sf::IntRect(1, 1, sprite.GetSize().x-1, sprite.GetSize().y-1));//To do avec le charset
}
else
std::cerr << "erreur fonction ImageManager.GetSpriteEnemy appelée avec whichEnemy = " << whichEnemy << std::endl;
}
示例6: MakeSprite
void Tileset::MakeSprite(int tile_id, sf::Sprite& sprite)
{
assert(tile_id < COUNT);
sprite.SetImage(GET_IMG("tileset"));
// on calcule le subrect de la tile grâce à son id
// (la tile première tile haut-gauche du tileset a l'id 0)
sf::IntRect rect;
rect.Left = (tile_id % WIDTH) * Tile::SIZE;
rect.Right = rect.Left + Tile::SIZE;
rect.Top = (tile_id / WIDTH) * Tile::SIZE;
rect.Bottom = rect.Top + Tile::SIZE;
sprite.SetSubRect(rect);
}