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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - vechestva

Pages: [1] 2
1
Graphics / Re: How to rotate sprite, keeping the original position?
« on: June 27, 2014, 12:17:25 am »
I want that it changed an angle on center. :P

2
Graphics / How to rotate sprite, keeping the original position?
« on: June 26, 2014, 11:45:08 pm »
How to rotate sprite, keeping the original position? Sprite position changes every time. It goes to ~ 300 degrees. :)
Sprite* square;
....
square->SetRotation((float)rand()%360);
 

3
System / Re: How to create a thread(with args) from the method?
« on: March 27, 2014, 05:57:57 pm »
Thanks to all! ;D

4
System / How to create a thread(with args) from the method?
« on: March 27, 2014, 12:42:29 am »
Hi!

How to create a thread(with args) from the method?

class A
{
public:
    A()
    {
         // understood that does not work
         pThread = new sf::Thread(std::bind(&Method, 15, 25), this));
    }
    ~A()
    {
         delete pThread;
    }
    void Method(int a, int b);

    private:
        sf::Thread* pThread;
};
 

5
Network / Re: How read recive data? (const void*)
« on: March 27, 2014, 12:37:20 am »
Thanks!

6
Network / How read recive data? (const void*)
« on: March 26, 2014, 07:10:57 pm »
Hello! I need to read the incoming packets.

I can not make it through sf::Packet, since the structure of the package is not known.
I need to convert the received packet data(const void*) to "classical" set bits in hex ​​format. (example: 00:00:00:04:00:00:00:0c:68:65:6c:6c:6f:20:73:65:72:76:65:72)

ps: by TcpSocket

7
Graphics / Re: How to create a copy of the class?
« on: January 12, 2014, 11:46:36 am »
Well, pardon me, but why would you want to do such a thing?
To modify the base class.

8
Graphics / How to create a copy of the class?
« on: January 12, 2014, 06:35:49 am »
Greetings!
I want to make a base class Depictable for graphics that will hold my methods.
It inherits from sf :: Drawable.
class Depictable: public sf::Drawable
{
            ...
    public:
            virtual ~Depictable() {}

    private:
            void draw(sf::RenderTarget& target, sf::RenderStates states) const {}
            ...
};
 
I want to do is an exact copy of the class sf :: RectangleShape.
class Rectangle : public Depictable,  public sf::RectangleShape
{
    public:
                virtual ~Rectangle() {}
                explicit Rectangle(const sf::Vector2f& size = sf::Vector2f(0, 0)) { setSize(size); }
};
 
and then draw it.
        Rectangle* line = new Rectangle(sf::Vector2f(50, 10));
        line->setFillColor(sf::Color::White);
        line->setPosition(100, 100);
        app.draw(*line);
 
Naturally, the line is drawn.
How to make a class so that it is drawn?
except sf::RectangleShape* line = new Rectangle(sf::Vector2f(50, 10));

9
General / Re: Question about destructors of some classes.
« on: May 18, 2013, 01:46:25 pm »
The thread is still active, you have to manually call thread->terminate().
No, you should not call terminate() in normal situations. sf::Thread::~Thread() invokes wait(), therefore it waits until the thread is finished. Just let your thread end regularly.

Concerning sf::TcpSocket, the base class destructor ~Socket() invokes close().
Thanks, now I understand.

What is the "processing status"?
Whether running launch()?
I would like to use a list of pointers to thread (std::list<sf::Thread*>), but i have to use a pair. (std::list <std::pair<sf::Thread*, bool /*isLaunched*/>>) or a map.

10
General / Question about destructors of some classes.
« on: May 18, 2013, 01:23:03 pm »
Good day.
I have a question.
Why destructors some classes:
sf::~TcpSocket, sf::~Thread
do not call methods:
sf::TcpSocke::disconnect(),  sf::Thread::terminate()
?
When using them appear some discomfort, for example:
sf::Thread* thread= new sf::Thread(&fooo);
thread.launch();
...
delete thread;
The thread is still active, you have to manually call thread->terminate().

ps: And yet, it would be nice to add the processing status for threads. (sf::Thread::Status)

11
System / Re: SFML in the future.
« on: March 18, 2013, 11:33:30 am »
Fixed the last post

12
System / Re: SFML in the future.
« on: March 18, 2013, 11:16:04 am »
...
You do not understand me. I was referring to the cast to the parent class.
Example even have to SFML:
classes Shape, Sprite and Text are the methods of Transformable, so they inherit from him.
It follows from this that I can use methods getPosition() and I do not need to know which type is inherited particular instance Drawable.

for example:
void Object::Foo(sf::Transformable* transformable)
{
    ...
    transformable->getPosition();
    ...
}


sf::Shape* rect = new sf::RectangleShape;
...
object.Foo(dynamic_cast<sf::RectangleShape*>(rect));
 

13
System / Re: SFML in the future.
« on: March 18, 2013, 10:21:08 am »
I guess the question is: Will getLocalBounds and getGlobalBounds get moved to the parent class? Right?
yep.

Quote
If so then the answer is no.
The two functions exist only for convenience and not all of the transformable would need those functions. Besides that it's very easy to add such functionality to a derived class, if you need them.
This is problematic in my situation.
For example, I want to write a common function of demand for Drawable, but the methods of getGlobalBounds and getLocalBounds declared  separately in each class (Shape, Sprite, Text,  VertexArray?).
I make do with templates and type checking.((

14
System / Re: SFML in the future.
« on: March 18, 2013, 09:59:44 am »
Will there be moved methods getLocalBounds, getGlobalBounds to parent class?

15
System / SFML in the future.
« on: December 19, 2012, 08:10:50 pm »
Will there be any in the library of methods for process management and implementation of the singleton pattern?


Sorry for my English.

Pages: [1] 2
anything