SFML community forums
Help => Graphics => Topic started by: d3ftp on October 26, 2011, 08:40:50 pm
-
How move rectangle? I try set it on central position and i have problem with this.
sf::IntRect r1(200, 200, 400, 400);
http://ifotos.pl/zobacz/obrazekpn_hqawsrp.png/
-
Uhm, i think you'll have to show some more code. an IntRect isn't drawable, an sf::Shape is on the other hand. Create drawable rectangles using sf::Shape::Rectangle(xpos, ypos, xsize,ysize,color,outline,outlinecolor);
-
i don't want draw shapes. i want cut out part from image, for example : I want cut out only circle with this image.
http://ifotos.pl/zobacz/circlejpg_hqqwspn.jpg/
-
You want Sprite::SetSubRect() from the sounds of it.
Make an intrect then pass it to SetSubRect.
-
like this?
#include "libs.h"
using namespace std;
int main()
{
sf::Event Event;
sf::IntRect r1(400, 400, 800, 800);
sf::Image test;
test.LoadFromFile("background.png");
sf::Sprite test2;
test2.SetImage(test);
test2.SetSubRect(r1);
sf::RenderWindow Window(sf::VideoMode(800,600,32),"aaa");
while(Window.IsOpened())
{
while(Window.GetEvent(Event))
{
//Close Window
if(Event.Type == sf::Event::Closed)
Window.Close();
}
// Window.Clear(sf::Color( 125,125,125 ));
Window.Draw(test2);
Window.Display();
}
return 0;
}