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

Pages: [1]
1
General / Sprite Pointer?
« on: January 08, 2020, 08:50:58 pm »
Hy how can i get a sprite as a pointer?

I've tried:

Sprite Piece_1;
Sprite* Selected_Piece;
Selected_Piece = Piece_1;

and it doesn't work.
it says that can't convert a Sprite to Sprite*;


I need this because I am making a game, and I need a pointer to a sprite, base on a switch(ID_Piesa) selected from multiples sprites;
If there is another way, can you tell me?

2
General / Re: Sprite confined to screen--Help--Beginer
« on: January 04, 2020, 12:24:44 am »
You can just check to make sure the mouse position is within the size of the window before setting the boat's position to it.

I haven't thought of that... Thanks :)

3
General / Sprite confined to screen--Help--Beginer
« on: January 03, 2020, 09:23:35 pm »
So I am trying to make a sprite to stay on screen, when my mouse is off-screen, and when the button is pressed.

The code:

    Texture Temp;
    Temp.loadFromFile("./Tiles/Boat.png");
    Sprite Boat(Temp);
    Boat.setScale(1.0, 1.0);
   
    Event Action;
    Keyboard Tastatura;
    while (Game.isOpen())
    {
        while (Game.pollEvent(Action))
        {
            if (Action.type == Action.Closed)
            {
                Game.close();
            }
            if (Action.key.code==Tastatura.Space  )
            {
                Boat.setPosition(static_cast<sf::Vector2f>(MousePoz.getPosition(Game)));
            }
        }
        Game.clear(Color(139,0,139,255));
        Game.draw(Boat);
        Game.display();
    }

Basically, when I press space, the sprite moves to my mouse position relative to the Game Window.
the problem is that when my moves out of the game window and space is pressed, the sprite moves off-screen too...

The boat is a small picture, and it loads correctly.

What can I do?

PS: Sorry if I made spelling mistakes.

Pages: [1]
anything