Jump to content

Menu Mouse


fumanshoo
 Share

Recommended Posts

So, I haven't been able to work on this too long or too hard, but I want my mouse to stop rotating around my controller ( or pivot in this case ) and start moving freely around the screen when I press "K" and stop moving and then start rotating around my controller ( or pivot in this case ) when I press "K" again. So basically a menu. Here's my code. Please don't judge if it's completely off...

 

--mouse
if KeyHit (KEY_K)==1 then
 if mouse== 1 then
  mouse = 0
  ShowMouse(mouse)
  MoveMouse(GraphicsWidth(),GraphicsHeight())
  mx=Curve(MouseX()- GraphicsWidth(),3.0/AppSpeed())
  my=Curve(MouseY()- GraphicsHeight(),3.0/AppSpeed())
else
  mouse = 1
  HideMouse(mouse)
  MoveMouse(GraphicsWidth()/2,GraphicsHeight()/2)
  mx=Curve(MouseX()- GraphicsWidth()/2,3.0/AppSpeed())
  my=Curve(MouseY()- GraphicsHeight()/2,3.0/AppSpeed())
 end
end

 

So far, it shows and hides the mouse, but other than that, nothing happens...

Link to comment
Share on other sites

mouse = 0

While AppTerminate == 0 do

if KeyHit(KEY_K) == 1 then
 mouse = 1
 function FlipHook()

    MoveMouse(GraphicsWidth(),GraphicsHeight())
    mx=Curve(MouseX()- GraphicsWidth(),3.0/AppSpeed())
    my=Curve(MouseY()- GraphicsHeight(),3.0/AppSpeed())
 end


end

 

Not sure what you exactly want to achieve... with the K key, but I use an GUI button to close it again. but this will hold it on screen.

because the mouse = 0 which was declared before main loop.

it's not perfect but an start and will definitely work

Link to comment
Share on other sites

mouse is being declared outside the 'lexical scope' but because it is not declared with the local keyword it is being put in global scope which lets it work.

 

In general global variables should be looked down upon. However after you find out why they are bad you will go through a dogmatic period of time where principles are the law of the land. Then after mastery is acquired you go back to breaking all of the rules whenever you feel like. So I guess I don't know what to say...

 

ShowMouse and HideMouse do not require a parameter.

 

I would leave the mx, my variable as they were and not set them in the gui loop. Also you do not need to use MoveMouse in the gui loop since you are moving that on your own. The MoveMouse command is often used to set the mouse back to the middle of the screen programatically when you have moved it manually. Due to the way the Curve function works it lags behind.

 

I hope this helps.

Link to comment
Share on other sites

@ Dennis, I forgot to add that I have my mouse = 0 before the main loop, and I am using "K" because I have run out of keys and I am not smart enough to do something like press escape and then use GUI because I am already using escape to end the program... Anyways, when I use your script, my mouse goes to the right corner and then freaks out and I can't go back to normal... I think that has to do with the function FlipHook because that didn't really do anything like change colors or anything like that...

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...