How to get mouse position with the layout object

For questions about using Classic.

Post » Wed Jun 29, 2011 5:36 pm

so i'm trying to make a menu in game using the layout object, which is what it seems like it was made for. but the layout object window gets its mouse position from the mouses position relative to the x/y of that layout object layout. not the actual mouse position. making using the mouse in the layout object worthless unless its exactly lined up with the corner of the screen.

is there any way to get the mouse to work as it appears to be on screen?Bartosh2011-06-29 17:39:03
B
6
S
2
G
5
Posts: 249
Reputation: 2,323

Post » Wed Jun 29, 2011 9:42 pm

http://dl.dropbox.com/u/9050706/Cap%26autre/menu.cap

here you got an example how to make a menu.
B
3
S
2
G
2
Posts: 136
Reputation: 1,347

Post » Thu Jun 30, 2011 4:00 am

hmmmmmm. bit of miss communication I suppose. I understand how to change layouts.

my question is with the layout object. I'm trying to use it to make a rts like build menu.
however the mouse in the layout object is not were the actual mouse is at.

thanks for trying to help though.
B
6
S
2
G
5
Posts: 249
Reputation: 2,323

Post » Thu Jun 30, 2011 5:54 am

I find the best way to make a hud is to use inheritance layers. Its a little known feature but its pretty awesome. basically you can set a layer to inherit from a layout in its properties. just make sure to include that layouts event sheet! I dont have time to make a proper example but a search on the forums should bring one up!
B
5
S
2
G
4
Posts: 632
Reputation: 2,829

Post » Thu Jun 30, 2011 8:31 pm

Get the mouse position from the System object.
Mouse.X
Mouse.Y
B
30
S
6
G
5
Posts: 433
Reputation: 6,061

Post » Thu Jun 30, 2011 9:30 pm

You can do it with global variables to transfer the coordinates.

ex:
LayoutMouseX = MouseX - Layout.Left
LayoutMouseY = MouseY - Layout.Top

Then just use those global variables for mouse coordinates in the Layout in the Layout object.

http://dl.dropbox.com/u/5426011/examples5/layoutmouse.cap

Keep in mind that you'll have to event accordingly. For instance you will no be able to use "on object clicked". Instead you'll have to use "on click" and "object overlaps point".
B
79
S
24
G
54
Posts: 4,746
Reputation: 40,755

Post » Thu Jun 30, 2011 11:29 pm

hey thanks R0J0hound exactly what i was looking for. you're awesome.

Aeal5566 I've never worked with inheritance layers before. sound like something worth experimenting with.
Bartosh2011-06-30 23:31:03
B
6
S
2
G
5
Posts: 249
Reputation: 2,323


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 3 guests