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

Pages: [1]
1
General / Re: Moving a view with mouse
« on: November 08, 2019, 12:01:57 pm »
did you try this from the tutorials?

You're probably right ! I'll try this later, it should solve my problem !  ;D

2
General / Moving a view with mouse
« on: November 08, 2019, 11:35:08 am »
Hi,

My function is working well but the mouse is moving a bit faster than the view and that's really ennoying  :-\ Is there a way to synchronize them ?
if (event.type == Event::MouseMoved) {
                                if (!moving || !checkMouseOnGameView(static_cast<Vector2f> (Mouse::getPosition(window)), window))
                                        break;
                                p1IconSprite.setColor(Color(0, 0, 0, 0));
                                const sf::Vector2f newPos = sf::Vector2f(event.mouseMove.x, event.mouseMove.y);
                                Vector2f deltaPos = oldPos - newPos;
                                deltaPos.x *= accumZoom;
                                deltaPos.y *= accumZoom;
                                gameView.move(deltaPos);
                                window.setView(gameView);
                                oldPos = newPos;
                        }
 

3
Graphics / Re: Sprites Vector
« on: October 25, 2019, 10:40:10 am »
Finally ...

playerIconVectorTexture.reserve(playerIconNumber);
playerIconVectorTexture.insert(playerIconVectorTexture.begin()+i, playerIconTexture);
playerIconSprite.setTexture(playerIconVectorTexture[i]);
 

With this it's working perfectly. Thank to both of you  ;) !

4
Graphics / Re: Sprites Vector
« on: October 25, 2019, 09:46:26 am »
This is a really good idea and I already tried to do this ;D :

playerIconSprite.setTexture(playerIconVectorTexture.front());

On the first post you can see that I have two vector : one for sprites and the other for textures. But it does not work anyway  >:(

5
Graphics / Re: Sprites Vector
« on: October 25, 2019, 08:35:55 am »
Thank you ! Stauricus I already tried to replace insert() with push_back() but it didn't change antyhing  :-[
Is there a nice way to draw a large number of sprite (that have the same properties) ? I can copy paste my code for each sprite but I think it's not really elegant ...

6
Graphics / Sprites Vector
« on: October 23, 2019, 05:21:56 pm »
Hey !

I want to draw a few Sprites which are located in the same folder (assets/playerIcon/NUMBER.png).
I don't understand why my code isn't working. On my app I can only see the last sprite and the others are just replaced by a white square.
Could someone help me ? Thank you in advance !

static vector<Sprite> playerIcon;
static vector<Texture> playerIconVectorTexture;
int playerIconNumber = 4;
for (int i = 0; i < playerIconNumber; i++) {
                std::string fileLocation = "assets/playerIcon/";
                fileLocation += std::to_string(i) + ".png";
                std::cout << fileLocation << std::endl;
                Texture playerIconTexture;
                Sprite playerIconSprite;

                if (!playerIconTexture.loadFromFile(fileLocation))
                {
                        writeToLog("Error");
                        exit(0);
                }
                else {
                        playerIconTexture.setSmooth(true);
                        playerIconVectorTexture.insert(playerIconVectorTexture.begin(), playerIconTexture);
                        playerIconSprite.setTexture(playerIconVectorTexture.front());
                        playerIconSprite.setPosition(Vector2f(200+(i*100), 400));
                        playerIcon.push_back(playerIconSprite);
                }
        }
 

And later :

for (Sprite x : playerIcon) {
        window.draw(x);
}
 


Pages: [1]
anything