Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: How move rectangle ?  (Read 1889 times)

0 Members and 3 Guests are viewing this topic.

d3ftp

  • Newbie
  • *
  • Posts: 7
    • View Profile
How move rectangle ?
« on: October 26, 2011, 08:40:50 pm »
How move rectangle? I try set it on central position and i have problem with this.
 
Code: [Select]
sf::IntRect r1(200, 200, 400, 400);

http://ifotos.pl/zobacz/obrazekpn_hqawsrp.png/

Haikarainen

  • Guest
How move rectangle ?
« Reply #1 on: October 27, 2011, 08:03:10 am »
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);

d3ftp

  • Newbie
  • *
  • Posts: 7
    • View Profile
How move rectangle ?
« Reply #2 on: October 30, 2011, 11:48:55 am »
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/

thePyro_13

  • Full Member
  • ***
  • Posts: 156
    • View Profile
How move rectangle ?
« Reply #3 on: October 30, 2011, 12:24:45 pm »
You want Sprite::SetSubRect() from the sounds of it.

Make an intrect then pass it to SetSubRect.

d3ftp

  • Newbie
  • *
  • Posts: 7
    • View Profile
How move rectangle ?
« Reply #4 on: October 30, 2011, 03:17:34 pm »
like this?
Code: [Select]

#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;
}


 

anything