Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: [SOLVED] The RectangleShape outline is always red  (Read 1701 times)

0 Members and 1 Guest are viewing this topic.

NoRain

  • Newbie
  • *
  • Posts: 3
    • View Profile
    • Email
[SOLVED] The RectangleShape outline is always red
« on: December 21, 2018, 12:16:53 pm »
I have a grid of RectangleShapes in my project:

And when I try to add an outline to a cell
m_rect.setOutlineColor(sf::Color::Cyan);
m_rect.setOutlineThickness(1.f);
 
* m_rect's type is RectangleShape

I looks like this:


uname -a
(click to show/hide)
sfml version: 2.5.1-1

What am I doing wrong?
« Last Edit: December 23, 2018, 12:04:32 pm by NoRain »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: The RectangleShape outline is always red
« Reply #1 on: December 21, 2018, 12:54:15 pm »
If would be helpful if you could try and post a complete and minimal example that reproduces the problem.
Laurent Gomila - SFML developer

NoRain

  • Newbie
  • *
  • Posts: 3
    • View Profile
    • Email
Re: The RectangleShape outline is always red
« Reply #2 on: December 21, 2018, 04:29:32 pm »
I've tried to reproduce this in a small example, but there it works fine. The outline color is cyan.
So, here is a piece of my project's code: https://pastebin.com/hfG6zxFi.

I draw cells with this code
m_cells[i][j]->draw(target, states);
 
and then just call select/unselect everytime a player clicks on a cell.

Sorry that there's not a small example.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10815
    • View Profile
    • development blog
    • Email
Re: The RectangleShape outline is always red
« Reply #3 on: December 21, 2018, 07:58:01 pm »
It's something in your code, try to reduce the existing code until you reach something more like the minimal example you've created. Along the way you should notice what makes the behavior change.
Or start with the minimal example and keep adding your code until you get a similar code base.

Took a look at the posted code, didn't see anything obvious, but the issue is probably in some code piece you don't expect it...
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

NGM88

  • Full Member
  • ***
  • Posts: 162
    • View Profile
Re: The RectangleShape outline is always red
« Reply #4 on: December 22, 2018, 06:23:17 pm »
If StackOverflow has taught me anything, it's this:

The code in your question MUST meet the following criteria

1. The code must compile and run when you copy/paste it to an empty (sfml-linked) project.
2. The code must reproduce the problem.

When both criteria are met, you will usually be able to see the solution before even finishing your post.

Even if you can't, you increase your chances of getting a solution from someone else by a zillion percent.

NoRain

  • Newbie
  • *
  • Posts: 3
    • View Profile
    • Email
Re: The RectangleShape outline is always red
« Reply #5 on: December 23, 2018, 11:37:22 am »
Ok, I've found the problem. It is always red because I set the outline color to red in another function. Sorry, it was silly. I thought it was a bug, but it all because of my inattention.
« Last Edit: December 23, 2018, 12:03:16 pm by NoRain »

 

anything