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.


Topics - Nero

Pages: [1]
1
Graphics / Fade in - fade out transition function
« on: August 31, 2018, 02:28:09 pm »
Hello there!
I have a rectangle shape with the size of the window.
I'm trying to create a transition effect that fades in the rectangle and then fades out when the first fade is fully completed.
This whole effect starts when someBool == superiorBool::True and ends when someBool == superiorBool::Unitialized.

void Application::transition()
{
        transitionRectangle.setFillColor(sf::Color(0,0,0, transitionRectangleAlphaChannel)); // transitionRectangleAlphaChannel is initialized as 0 by default

        if (transitionClock.getElapsedTime().asSeconds() > 0.1f && transitionRectangleAlphaChannel < 255.f && someBool == superiorBool::True)
        {
                transitionClock.restart();
                transitionRectangleAlphaChannel += 5;
        }
        else if (transitionClock.getElapsedTime().asSeconds() > 0.1f && transitionRectangleAlphaChannel > 0.f && someBool == superiorBool::False)
        {
                transitionClock.restart();
                transitionRectangleAlphaChannel -= 5;
        }

        if (someBool == superiorBool::True && transitionRectangleAlphaChannel == 255)
        {
                someBool = superiorBool::False;
        }
        else if (someBool == superiorBool::False && transitionRectangleAlphaChannel == 0)
        {
                someBool = superiorBool::Uninitialized;
        }
 

For some reasons it doesn't work. Any ideas?
Thanks in advance!

2
Graphics / [SOLVED]Combine 2 sprites into a single one?
« on: July 23, 2018, 08:52:42 am »
So, I am facing this problem:


Basically, I have 2 rectangles ( body shadow and gun shadow ), each one having a black texture with 40% opacity that goes up to 80% in the place where they intersect. Is there a way to make the shadows appear as a single shape?

Thanks in advance !

3
Window / Minimize the window
« on: June 20, 2018, 11:21:44 am »
Hello guys! I've created a custom titlebar that's fully working EXCEPT the minimize button. I can't minimize the window even if I try to do it from the windows taskbar. Any ideas? I would prefer one that's not Windows-specific but if there is no other solution, I'd be grateful to hear the windows one too! :D



Edit: Wow, that's a big image lol.

4
General / Custom Titlebar
« on: May 18, 2018, 02:40:32 pm »
Is there a way to create a custom titlebar using SFML?

Or at least vanish the actual titlebar (white thing from image below) so I can create a custom one using rectangles?


5
Is it necessary to use delta time if I capped the frame rate? How exactly does the frame rate function work?

6
General / C++ & SFML class vector - showing the wrong texture
« on: May 09, 2018, 04:24:53 pm »
So, my problem is this : I have a class called thing. The class basically creates a rectangle with a texture. When I'm drawing the rectangle on the window without using a vector, all works fine, but when I do, it takes the wrong texture (another texture from the same folder) even tho in the class it says nothing about that texture.

Here is the code :

Main.cpp
#include <SFML/Graphics.hpp>    
#include <iostream>
#include "thing.h"
#include <vector>

int main()
{
    sf::RenderWindow window(sf::VideoMode(1280, 720), "whatever", sf::Style::Close);

    std::vector<thing> things;
    things.emplace_back(thing());

sf::Texture textureanother1;
textureanother1.loadFromFile("textures/another1.png");

sf::Texture textureanother2;
textureanother2.loadFromFile("textures/another2.png");

sf::RectangleShape another1(sf::Vector2f(132.0f, 94.0f));
another1.setTexture(&textureanother1);
another1.setOrigin(66.0f, 94.0f);
another1.setPosition(500.0f, 680.0f);

sf::RectangleShape another2(sf::Vector2f(126.0f, 55.0f));
another2.setTexture(&textureanother2);
another2.setOrigin(63.0f, 55.0f);
another2.setPosition(500.0f, 605.0f);

    while (window.isOpen())
    {
        sf::Event evnt;
        while (window.pollEvent(evnt))
        {
            if (evnt.type == sf::Event::Closed)
            {
                window.close();
            }
            else
            {
                break;
            }
        }

        window.draw(another1);
        window.draw(things.at(0).thingItem);
        window.draw(another2);
        window.display();
    }
    return 0;
}

Thing.h

#pragma once

#include <SFML/Graphics.hpp>

class thing
{
public:
    thing();
    ~thing();

    sf::Texture thingTexture;
    sf::RectangleShape thingItem;
};

Thing.cpp

#include "thing.h"

thing::thing()
{
    thingTexture.loadFromFile("textures/sometexture.png");
    thingItem.setTexture(&thingTexture);
    thingItem.setSize(sf::Vector2f(16.25f, 99.25f));
    thingItem.setOrigin(8.125f, 99.25f);
    thingItem.setPosition(500.0f, 99.25f);

}

thing::~thing() = default;

Again, ALL other rectangles except the one created with the class and a vector work fine. The one created with a class and a vector works fine ONLY when it's used without a vector. What is wrong? There are no errors or warnings.

Instead of that : (which is showed when I use the class thing without a vector)



It shows that : (I used a vector, like in the code)



PS: I changed a bit names and deleted commens so you won't be confused by the strange words.

Pages: [1]
anything