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 - G.

Pages: 1 ... 3 4 [5] 6 7 ... 63
61
Graphics / Re: Text at center of rect
« on: August 13, 2021, 05:51:36 am »
Not sure that's what's happening because you didn't post a picture of the problem, but if the top left corner of your text is at the center of your rectangle, then it can be because you didn't set a font/string/size to your sf::Text before using its bounds. (its width and height would be 0)

62
Graphics / Re: Unique names for rectangles in class
« on: August 08, 2021, 07:58:11 pm »
If you need a fixed number of rectangles you can use arrays, old school arrays or std::array from the standard library.

63
Graphics / Re: Unique names for rectangles in class
« on: August 08, 2021, 07:10:18 pm »
If you want an undefined number of rectangle, you'll need a container (and learn how to use it), like an std::vector from the C++ standard library

64
General / Re: SFML GUI buttons design
« on: August 01, 2021, 08:56:09 am »
You can draw them on an sf::RenderTexture that is the size of the viewable area you want, and display this texture with a sprite.

65
General / Re: Help with animating non rectangular sprite
« on: June 30, 2021, 12:38:36 pm »
I'm not totally sure what you mean, but you can make the background of your sprite transparent (directly in the PNG) and anything you put behind it will be viewable

66
General / Re: Sprites-mouse input
« on: June 27, 2021, 12:09:58 am »
I barely understand now what you're trying to do.
You want to display an image at the position of your click, every time you click somewhere. Right? If not please be more explicit.

First things first, clearing the screen isn't some optional step. Every frame you clear the screen, you draw your shit, and you call display. There isn't any clear in your code.
If you want your board to "stay" on the screen, then draw it every frame.

If you want to react to a click, use the MouseButtonPressed event. Code inside the event will be triggered only once when you click. And that should probably be "add an X to this position".

To do that, you can create an empty std::vector of rectangles at the start of your program, and everytime the MouseButtonPressed event is triggered you create a new rectangle, set its size, color, texture or whatever, set its position to the position of the click, then you add it into you vector.
After your event loop, clear the window, draw your board, iterate through your vector to draw every rectangle, call display.


67
General / Re: Sprites-mouse input
« on: June 26, 2021, 06:35:23 pm »
It would be better to show what you tried and explain how it "doesn't work" so that we can correct it

68
General / Re: Sprites-mouse input
« on: June 25, 2021, 09:59:30 pm »
Create a list or vector or whatever of RectangleShape or sprite.
Then use events, the MouseButtonPressed event. When a mouse button is clicked, create a rectangle at the position of the click.
Finally, somewhere between your clear and display, draw all the rectangles contained in your list.
(as said in the tutorials, not using clear/draw/display sucks)

69
Graphics / Re: Inheritance from Shape
« on: June 06, 2021, 05:24:47 pm »

70
3) or use transform.rotate and pass the resulting transform to the draw function when drawing the circle

71
Graphics / Re: CSFML window not drawing rectangle shape
« on: May 22, 2021, 05:52:13 pm »
Have you set the size of your rectangle?

72
General / Re: Get Keyboard input without a window(Console)
« on: May 10, 2021, 05:25:16 pm »
You'd have to keep an array of what keys are pressed, update it every step of your main loop, and when a key is pressed but wasn't pressed before it will mean it has been pressed right now, like a "short pulse" I guess

73
General / Re: Get Keyboard input without a window(Console)
« on: May 10, 2021, 07:51:27 am »
C++ standard input, cin, if you want to get some text or numbers from your console
https://www.cplusplus.com/doc/tutorial/basic_io/

sf::Keyboard::IsKeyPressed if you have other needs...
https://www.sfml-dev.org/documentation/2.5.1/classsf_1_1Keyboard.php

74
General / Re: makefile error?
« on: April 24, 2021, 08:40:42 am »
Do we need 4 bad threads for the same problem?
People can't even read your makefile because you keep posting half-assed screenshot to show TEXT... 

sfml-windows doesn't exist.

75
Graphics / Re: problem with drawing multiple objects
« on: April 12, 2021, 03:09:31 am »
It works...
But you have to use a reference if you don't want to modify a copy.

Pages: 1 ... 3 4 [5] 6 7 ... 63
anything