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

Pages: [1]
1
Graphics / Re: AW: Strange sf::Text top margin.
« on: October 09, 2016, 10:03:27 am »
What does the documentation and tutorial say?

I'm really sorry but I couldn't find anything about baseline alignment mentioned by Laurent except for single glyph in "Making your own text class" part.

Is it supposed to be there?
http://www.sfml-dev.org/tutorials/2.4/graphics-text.php
http://www.sfml-dev.org/documentation/2.4.0/classsf_1_1Text.php

Thank you for your replies.

2
Graphics / [SOLVED] Strange sf::Text top margin.
« on: October 08, 2016, 08:43:06 pm »
Hello everyone!

I've got problem with displaying sf::Text correctly. Below is the code I use:

// Load font in OnInit() and create text.
sf::Font * font = new sf::Font();

if (!font->loadFromFile(path)) // loads courier new
{
        // some code
}

sf::Text text = sf::Text("A+", *font, 18);
text.setColor(sf::Color::Red);
text.setOrigin(0.f, 0.f);

// ...

// Draw text in Draw()
_window.draw(text);

// ...

Provided code is just an example that contains most important parts (I store texture pointer correctly etc, so no worries).

The result is strange, because the text has strange top margin (it's not drawn exactly at top left corner, or is it?). Is it font's feature or I do something wrong? I've tried "Arial" and there was similar behaviour.

See the attachment for visual view.

3
Graphics / Re: Handle mouse click on non-transparent part of sprite.
« on: October 05, 2016, 06:31:12 pm »
I see, thank you for your reply. For the provided example texture it's not worth at all, however it was just an example to simplify the question. The actual shapes are much more complex (mostly concave).

4
Graphics / [SOLVED] Handle mouse click on non-transparent part of sprite.
« on: October 05, 2016, 05:12:41 pm »
Hello everyone!

I am trying to handle clicks on non-transparent part of sf::Sprite. I've created texture in .png format which contains transparent background. I handle clicks with following code:

zones = ...;
sf::Sprite someSprite = ...;

MouseState mState = InputManager::I().GetMouseState();

for (int i = 0, size = zones.size(); i < size; ++i)
{
   
   if (mState.LeftButtonClicked && someSprite.getGlobalBounds().contains(mState.PositionX, mState.PositionY))
   {
      // ... some code
   }

   // ... more code
}

Mouse state updates and clicks are handled properly, however clicks on the transparent part of the sf::Sprite are detected as inside sprite (which is correct I suppose, since getGlobalBounds returns (bounding?) rectangle).

I need to handle clicks only on visible part of the sprite.
Does SFML support such thing? If so, how to achieve that?
Do I have to handle this myself? If so, how to achieve that? (Not asking for actual code, but tips/algorithms/etc).

See attachment for visualisation and example texture file.


5
General / How to connect wxWidgets with SFML2?
« on: May 08, 2013, 09:06:43 pm »
Hello there!
I'm looking for some guide how to connect those 2 libraries (SFML drawing module in wxWidgets to be specyfic) but could find only those for SFML 1.6. Anyone got one for SFML2?
Thanks in advance.

Pages: [1]