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 - Ignatius_Z

Pages: [1]
1
Graphics / Re: How do I set a position/scale etc on a single axis?
« on: February 10, 2021, 04:35:44 am »
bump?

3
Graphics / Re: Why can't I transform from a function?
« on: February 09, 2021, 02:11:45 pm »
You pass the shape to the function by value, ie. inside the function you're working on a copy of it. To work on the original instance, pass it by reference.

so I just put a "&" after "RectangleShape" ?

4
Graphics / Why can't I transform from a function?
« on: February 09, 2021, 01:33:34 pm »
Pretty simple question. For example:

float deltaTime;

void rotateShape(RectangleShape currentShape);

int main()
{
        Clock theClock;
       
        RectangleShape myShape(Vector2f(100.f, 100.f));
       
        while (window.isOpen())
        {
                deltaTime = theClock.restart().asSeconds() * 60;
               
                rotateShape(myShape);
               
                myShape.rotate(5.f * deltaTime); // < this works
               
                myShape.move(10.f * deltaTime, 0.f); // < this works
               
                myShape.scale(1.01f, 1.01f); // < this works
;              
                Event event;
        while (window.pollEvent(event))
        {
            if (event.type == Event::Closed)
                window.close();
        }
               
                window.clear(Color(0,0,0));
        window.draw(myShape);
        window.display();
        }
}

void rotateShape(RectangleShape currentShape)
{
        cout << currentShape.getRotation() << endl; // < this works
       
        currentShape.rotate(5.f * deltaTime); // < this doesn't work
       
        currentShape.move(10.f * deltaTime, 0.f); // < this doesn't work
       
        currentShape.scale(1.01f, 1.01f); // < this doesn't work
       
        // etc.
}

Why don't the transform functions work when called from my own function?

As usual apologies for the probably noob question and thanks in advance.

5
Graphics / Re: How do I set a position/scale etc on a single axis?
« on: February 06, 2021, 03:44:11 am »
are you sure there isn't a way of just changing one part of the vector?

6
Graphics / How do I set a position/scale etc on a single axis?
« on: February 06, 2021, 01:07:10 am »
For example how do I use
sprite.setPosition(x, y);
but only for x OR y instead of both?

I used
sprite.setPosition(20, sprite.getPosition().y);
but i'd imagine thats not the most efficient way of doing it. Apologies again for the very noob question and its probably right in front of me but thanks in advanced.

7
I swear I already tried that but I tried it again and it worked. Thanks heaps  ;D

8
Graphics / Re: drawing a 1 pixel thick line
« on: February 02, 2021, 12:21:06 am »
is anti-aliasing on it or something?

9
Sorry for possibly very noob question but I've googled thoroughly and I don't where else to ask.

For some reason when using Sprite.move I can freely multiply the Vector2f I put in it but when I use Sprite.setPosition it gives an error.

for example:

int main()
{
     Sprite mySprite;

     Vector2f direction(1, 1);
     
     while (window.isOpen())
     {
            mySprite.move(direction * 0.5);
     }
}

This works fine but when I try:

int main()
{
     Sprite mySprite;

     Vector2f direction(1, 1);
     
     while (window.isOpen())
     {
            mySprite.setPosition(direction * 100);
     }
}

I get the error:

"no match for 'operator*' (operand types are 'double' and 'sf::Vector2f' {aka 'sf::Vector2<float>'})|"

Please let me know what the issue is and thanks in advance and sorry for any formatting errors :)

Pages: [1]