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

Pages: [1]
1
Graphics / Re: Wide string literal from string stored in variable
« on: August 15, 2019, 04:42:27 pm »
Rather than using wide characters, it's probably better to use UTF-8 encoded strings. They can be stored in standard (non-wide) strings.

The string literals would be specified like this:
u8"åäö"
What are the advantages of this compared to wide strings?

2
Graphics / Wide string literal from string stored in variable
« on: August 12, 2019, 01:20:47 am »
Im having trouble with some accented European characters (åäö). I have read the documentation, and I know that you are supposed to use a wide literal for SFML to be able to display these characters.

The font I am using has these characters, as I can create a sf::Text with the European characters. Say I have the following code snippets:

This one works as expected:

sf::Text t;
t.setString(L"åäö");
t.setFont(...);
window.draw(t);

which draws 'åäö'.

But I have no idea how to draw a string containing "åäö" from a string variable? I tried to do this:

std::string temp = "åäö";
sf::String s(temp);

sf::Text t;
t.setString(s.toWideString());
font, draw, etc...

I also tried this

std::string narrow_string("åäö");
std::wstring wide_string = std::wstring(narrow_string.begin(), narrow_string.end());
const wchar_t* result = wide_string.c_str();

sf::Text t;
t.setString(result);
font, draw, etc...

but that does not work either. Any ideas?

3
Graphics / Re: Checking if the mouse is on a sprite
« on: March 31, 2015, 11:53:19 am »
You can build such a function by combining sf::Sprite::getGlobalBounds() and sf::Rect::contains() :)

I'm having a problem tho. The getGlobalBounds function returns a sf::Rect<float>. I have no idea how to convert it to a regular float, and there doesn't seem to be anything online.

4
Graphics / Re: Checking if the mouse is on a sprite
« on: March 31, 2015, 11:12:04 am »
Thank you, this will help a lot! :)

5
Graphics / Checking if the mouse is on a sprite
« on: March 31, 2015, 10:56:49 am »
So in all of my SFML development, i've been doing manual checks to see if the mouse is currently hovering over a sprites area by comparing the current positions to the outer sides of the sprite. This is kind of annoying after a while if you have many buttons, and I'm just wondering if there was any function that I could use in order to get this result, some thing like mouseOnSprite(SpriteName);

Thanks

6
Network / Using HTTPS with SFML
« on: March 30, 2015, 12:40:15 pm »
Hello

I'm just wondering if It is possible to GET HTTPS requests using the Network module in SFML. I'm having problems with every other library that can use HTTPS.

7
General / Problem with resourcePath()
« on: January 16, 2015, 09:48:47 pm »
First of: I'm using Mac OS X 10.10.1 and Xcode 6.1.1.

Hello! I'm creating a program, and I need to use some shell to copy a file from a place to another. I get the pat of the file by doing
(resourcePath() + "files/buddyPanelAssets.swf")
. I'm also using this resourcePath  in the beginning of the code, to load fonts and textures etc. It looks like this
(resourcePath() + "segoeuil.ttf")

It works perfectly fine to load resources in the beginning, but once i use it in the middle of the code (in an if statement in this case) it returns this random crap. I used
cout << resourcePath() << endl;
to print the path, and I get this:
/Users/Sigge/Library/Developer/Xcode/DerivedData/CustomLoL-bdottywdqngdlwexzprwwdwfpyyx/Build/Products/Debug/CustomLoL.app/Contents/Resources/

This looks like the path that the build is running from, but i could be wrong.

What could be causing this? I know i could create a variable in the beginning and initialize it there and set it, and use it later. But I just want to know if something is wrong. Thanks!

8
General / Re: Xcode error: EXC_BAD_ACCESS (code=1, adress 0x0)
« on: January 05, 2015, 01:58:55 pm »
Oh well, I'll just use the normal way of displaying text. Thanks for the help

9
General / Re: Xcode error: EXC_BAD_ACCESS (code=1, adress 0x0)
« on: January 05, 2015, 01:15:00 pm »
Here, it's a ZIP file of a xcode project i made fast, the error happens when you run it.
https://www.dropbox.com/s/3gf0gctecrmptk7/CustomLoL%20kopia.zip?dl=0

10
General / Re: Xcode error: EXC_BAD_ACCESS (code=1, adress 0x0)
« on: January 05, 2015, 10:37:21 am »
I do know about scopes. This has worked before, and suddenly, it doesn't. I am declaring the variable before i use it and I'm declaring it in the same function.

11
General / Re: Xcode error: EXC_BAD_ACCESS (code=1, adress 0x0)
« on: January 05, 2015, 10:21:12 am »
I'm making the font with this:
sf::Font font;
        if (!font.loadFromFile(resourcePath() + "segoeuil.ttf")) {
            return EXIT_FAILURE;
        }

and then use it
text.push_back(sf::Text("blahblahblah",font,30));

After that i don't touch the variable at all, until I'm calling to draw the text. How can i make it stay alive longer?

12
General / Xcode error: EXC_BAD_ACCESS (code=1, adress 0x0)
« on: January 05, 2015, 06:49:30 am »
Hello guys! I'm just going to start off with some information. I am running Mac OS X 10.10, Xcode version 6.1.1, SFML 2.2. I am creating an app that lets you change some settings otherwise hard to change in a game, and I'm having a issue. I'm just going to say that I'm NOT a professional programmer, it's just a hobby that i've been doing for a while. I am not super good at it, so thats why I'm asking you guys!

I have a main.cpp file, which looks like this.
#include "main.h"
#include "langSelect.h"
#include "mainMenu.h"

using namespace std;

    int main(int argc, char** argv){
       
        mainMenu();
       
        return 0;
   
    }

It just calls the mainMenu method inside the mainMenu.h, which is just where i declare the method. In mainMenu.cpp, I'm displaying a menu with buttons and text. I declare these two variables in the beginning:
vector<sf::Text> text;
int textsNumber;

Then in the mainMenu method, i do
textsNumber = 0;

After that, i create text like this:
text.push_back(sf::Text("blahblahblah",font,30));

This can now be accessed like an array, like this:
text[0]

Now when it comes to clearing the window and drawing the text, i have a loop where it goes thought a set number (2 in this case, i only have 2 lines of text right now) of numbers in a loop. Remember that textsNumber is 0 as i set in the beginning.
while( textsNumber < 2){
                window.draw(text[textsNumber]);
                textsNumber++;
                if(textsNumber == 2){
                    textsNumber = 0;
                    break;
                }
            }

If i run this, the program launches and opens a window. But instantly, Xcode comes into focus and highlights
window.draw(text[textsNumber]);
in green and displays a text beside, that says Thread 1: EXC_BAD_ACCESS (code=1, adress 0x0) http://gyazo.com/c3ca45ae039ce6e17e9d08be008ca49a

It also does that on main.cpp: http://gyazo.com/317e1f147c9da652413473ce46fdcfb0

If i click the other tabs on the left side i see this:
http://gyazo.com/475feefd270519138c3a98a9dd424532
http://gyazo.com/73e99dcf657042ab477d1ce8c8357940
http://gyazo.com/d6edc312382865bdb11490b2d303ac9a

What could cause this problem? I have been searching all over google, only to find irrelevant information or very, VERY advanced guides on how to fix. If you want to see the whole source code, just tell me. Thanks.

Pages: [1]
anything