I'm trying to get the x, y, and state of my mouse in SDL. I tried using the lines
int mstate, mx, my = 0;
mstate, mx, my = SDL_GetCursor().SDL_GetMouseState();
But it gives me the error
C:[path]\particletest2\main.cpp|107|error: request for member
SDL_GetMouseState' in
SDL_GetCursor()', which is of non-class type `SDL_Cursor*'|
Is there any way I can get this to work? It seems like a waste to create a SDL_cursor object when SDL_GetCursor() should be creating one to return for you.
Thank you in advance for any help or answers, and for taking the time to read this.
-
http://www.libsdl.org/docs/html/sdlgetcursor.html
SDL_GetCursor()
returns a pointer and so you need to use the->
operator to access its member.Responding to your reply:
I think
mstate, mx, my = SDL_GetCursor()->SDL_GetMouseState();
is a problem if it wasn't incorrectly pasted. I do not think that this is doing what you think it should be doing, and I am not really sure what you think it should be doing.
-
Okay, when I tried that it told me SDL_Cursor was a struct, and not a object, If that's true how can it have functions?
After that I tried calling just "SDL_GetMouseState()" and it said I had to few arguments and needed to pass it a x, and y. I'm trying to get my mouses x and y though, so I can't pass what I need to something that gives me what I need.
Can someone please explain what's going on, because this just really confused me with how SDL handles mouse events and movements.
-
mstate, mx, my = SDL_GetCursor()->SDL_GetMouseState();
Using this gives me this error:
C:[path]\particletest2\main.cpp|107|error: 'struct SDL_Cursor' has no member named 'SDL_GetMouseState'|
Oliver N. : I assumed from your original post that SDL_GetMouseState was a member function of the SDL_Cursor struct/class, which it is not. http://linux.die.net/man/3/sdl_getmousestate shows that it is a function which is completely separate. -
Yes, which is why I said in my first reply:
After that [the -> operator] I tried calling just "SDL_GetMouseState()" and it said I had to few arguments and needed to pass it a x, and y. I'm trying to get my mouses x and y though, so I can't pass what I need to something that gives me what I need.
So, I am asking this now:
How do I get my mouse's X and Y in SDL [C++]?
Oliver N. : I think you should familiarize yourself with C++ before trying to tackle an SDL project, but the answer is something like: "int x = 0; int y = 0; SDL_GetMouseState(&x,&y);"
0 comments:
Post a Comment