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

Pages: [1]
1
+1 on Xploit post.

If you meant purely code wise, the way I usually do it is to use getGlobalbounds().contains like this  for example.

if you go the simple dirty way, just do one of these boundaries checks on mouse move (for highlight) and on mouse button press (for the actual action) and if they're true, do whatever you need to.

2
Cheers.

Just wanted to be sure to avoid doing it only to find out later on that it was already present.

3
Hey,

err, I do, but fail to see how it relates to what I posted. Probably didn't explain myself properly. :)

Say I want the user to be able to press A and click somewhere, and it does something.

Instead of storing a bool on keypress/keyrelease, I wanted to use sf::keyboard, which gives direct access to the keyboard state so I can just, on the Mousebutton event, check if sf::keyboard::a is pressed and that's it.

But add to that for example that I want to display, on click, the letter A somewhere (or any letter being pressed when mousebutton event pops up). My problem is that from the mousebutton event (where action is taken), I can know if the letter A is pressed, but how can I use that information, to know which letter to display?

I could make my own conversion function, inputting the sf::keyboard value and returning the converted ASCI value, but is there already such conversion function or any logic to the sf::keyboard enum relating to the ASCI/UNICODE tables?

4
Window / Logical link between sf::keyboard and ASCI/UNICODE tables?
« on: July 20, 2012, 09:07:15 am »
Morning,

Are there any SFML 2.0 function (or logic) to convert the sf::keyboard enum to an ASCI or UNICODE character table?

The idea is to be able to initialize a class (which is just to display sf:text, but with all events handling taken care of, etc) with a character, to make it a shortcut, and have the class handle the function to automatically edit the text and make all appropriate changes, like adding for example a "a) " in front of the current label text if we set that shortcut to "a", then react through events using sf::keyboard isPressed.

I've been using sf::keyboard to avoid tons of boolean stuff everytime sf::event:keyPressed pops up, but I'm having issues finding a logical conversion between the actual UNICODE key code, and sf::keyboard enum values and I can't just initialize with the enum directly, since I need to display the character in question.

So the question is, before I start doing my personal conversion function, is there already one in place?

5
General / Re: Undrawing Sprites and Shapes
« on: July 19, 2012, 05:37:41 pm »
Got it.  By the way, does anyone have source code for a simple game?  It would help to be able to see what an SFML game should look like.

Aside from the source in the SDK, I advise browsing some source repository like Github or others, sometimes you can find interesting stuff that expands the way you think and code, give you guidelines on which you can later build upon.

Here's one for example: https://github.com/krofna/Dreaming-Warrior
It's not code perfect or whatever, but the structure, and how it flows might help. There are plenty others around.


Nice blog btw Exploiter.

6
Graphics / Re: sf::Text in classes...font problem
« on: July 19, 2012, 05:26:25 pm »
Hmm.

So if you wanted to declare the sf::font in your main() or whatever, and use it in various classes, you'd need to pass it by pointer, then the sf::text (in the class) would store a pointer, to a pointer, of the font, which, since it's in the main, will remain until the end?

I think I tried that but probably screwed up somewhere. I'll try again later probably, once the brain is rested a bit.

Anyway, thanks Laurent.

7
Graphics / Re: sf::Text in classes...font problem
« on: July 19, 2012, 04:04:18 pm »
I did yes, at least I think so.

I had an epiphany however and I kinda solved my problem however....well it's working for now.

I went back to the basics, but instead of passing around the path/name of the font every time I created a new object, I use a config file, in which I store the fonts path & names (ie: font_menu, font_text, font_button, etc) and a classic sf::font in each class directly.
So when the constructor is called for the class, I read the config file, setup the proper sf::font depending on the variable I pass around for the font type I need from the file, then "= new" the sf::text pointer with that...and "roulez jeunesse" as we say in my country :)

Don't ask me why, works like a charm so far, no crash anywhere in sight and I finally got my DLL with labels, textarea, labellist, button and the like working without the default font, so not even a crash on exit now.

I still don't understand but it's obvious I was messing up somewhere, though it did not make any sense whatsoever.

I might try using some sort of #define pathname/fontname instead but I think I tried already and it was causing problems.

Anyhow, this font monkey business nearly drove me nuts, especially when everything else is working fine but you can't do that since the default font screws up :)

So consider this thread closed, though any details on how fonts work in relation to sf::text (they ARE linked, I'm sure of it, as soon as you link one with the other) would be appreciated.

8
Graphics / sf::Text in classes...font problem
« on: July 19, 2012, 03:15:37 pm »
Afternoon,

I'm working on some basic classes to have handy Labels, TextArea, InputBox, etc.

In all these, I use sf::text of course, and personal font as well and because of the default font crashing problem,  I've been using pointers to sf::Text in order to control how they initialize directly in the class constructor and a normal sf::font to hold the font, within each class. I figured, that way, the sf::font will stay alive as long as the object is..so no problem there...

That solved the default font crash but I then started getting insanely "wtf" issues on the sf::text draw function, each one regarding fonts in particular, as if they're no longer there at some point while they ARE still in the sf::font variables that was used to create the sf::text, for each objects. Made ZERO sense.

Then I figured: alright, let's make a sf::font right there at the start, and pass it around. But same issue again, when the draw calls arrive, it goes and starts doing font stuff...then returns that there's nothing there.

It's like...when you create a sf::text, it stores some address of something related to the font but can't find it later on!
As a note, everything fine if I just let the default font handle this, but of course, it crashes later on...and I can't use custom fonts...


So my question is...
If you want to put all sf::text calls into a class (let's say Clabel) how do you handle the font?

Another question would be: how the hell does sf::font work in relation to sf::text and especially draw calls?



Thanks in advance, that's driving me nuts :)

edit:
- oh, I use latest SFML 2.0 files, freshly made via CMAKE, and I'm on VS2010. I do have an ATI card (think it's related to the font issue if I got it right).

Pages: [1]
anything