Ok, this is the part i hate the most when i code.
I hope to find solutions although i dont expect any.
Ok, this is it. I've made a background image with 500 height. And i want to open a gui in the position of mouse.x, mouse.y . But if the mouse is on the edge of the screen, the gui opens out of the screen, so i want to change that.
I start to put in repeatedly_execute this
if (mouse.y >= (game.room_height-51)){
SetGUIPosition(2,mouse.x,game.room_height-51);}
But.... since room_height is bigger than 300 (as normal in a 640*480 game) the game doesnt recognize the mouse.y position!
I've made a test. This one : if (mouse.y > 200) Display("miau"); And it worked, but if i change it to 250, the display doesnt appear......
Oh, and i have to say, i've made a gui that is always (mouse.x, mouse.y) position, and if i put an hotspot, like in, x=200 and y=400, the label in the gui shows correctly the name of the hotspot, so the mouse.y workes there.
I just want an answer. Is it a coding mistake (i hope so!) or just a bug ?
Pardon me for the bad english.
ok, sorry to bother you, but i've already found. I didnt want to post but this was my last attempt but i found out :P
the game.room_height was 500, but i had to use the standart height - 250. So, i just did
if (mouse.y >= 189) (code) and it gave...
Sorry, i just know why it is! :-[
mouse.y returns the position of the mouse cursor on the screen, not the room.
So you could use screen.viewport_height instead of game.room_height.
Edit:
Or is it system.screen_height?
Try this:
if (mouse.y >= (system.screen_height - (51*2))) {
SetGUIPosition(2, mouse.x, game.viewport_height - 51);
}
Thanks. It works now! :D
I've appreciated your help ^^
I wouldn't use system.screen_height, because that'll screw up at 640x400 (since mouse.y is always in 320-res).
A slightly modified version of strazer's code should work:
if (mouse.y >= (system.viewport_height - (51*2))) {
SetGUIPosition(2, mouse.x, system.viewport_height - 51);
}
Ok, thanks for the correction.
Shouldn't it now be
if (mouse.y >= (system.viewport_height - 51)) {
SetGUIPosition(2, mouse.x, system.viewport_height - 51);
}
though?
Oh yeah sorry, didn't notice that bit ;)