2012-04-26 10 views

答えて

6

イメージをテクスチャ(SFML 1.6の場合はsf::Image、SFML 2.0の場合はsf::Textureのいずれか)にロードし、スプライトのサブレッジを設定します。 (SFML 2.0を使用して)このような何か:SFML 1.6の場合

sf::Texture texture; 
texture.loadFromFile("someTexture.png"); // just load the image into a texture 

sf::IntRect subRect; 
subRect.left = 100; // of course, you'll have to fill it in with the right values... 
subRect.top = 175; 
subRect.width = 80; 
subrect.height = 90; 

sf::Sprite sprite(texture, subRect); 

// If you ever need to change the sub-rect, use this: 
sprite.setTextureRect(someOtherSubRect); 

、それはより多くのこのようなものだ:あなたはどのように応じて、画像/テクスチャのための平滑化を無効にすることが

sf::Image image; 
image.LoadFromFile("someTexture.png"); // just load the image into a texture 

sf::IntRect subRect; 
subRect.Left = 100; // of course, you'll have to fill it in with the right values... 
subRect.Top = 175; 
subRect.Right = 180; 
subrect.Bottom = 265; 

sf::Sprite sprite(image); 
sprite.SetSubRect(subRect); 

注意あなたのスプライトを使用しています。スムージングを無効にしないと、エッジがブリードすることがあります(texture.setSmooth(false)またはimage.SetSmooth(false)など)。

+0

本当にありがとうございました! –