User Tag List

Results 1 to 6 of 6

Thread: Creating a circular bounding area for the cursor

  1. #1
    Clicker Multimedia Fusion 2 DeveloperAndroid Export Module

    Join Date
    May 2010
    Posts
    163
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Creating a circular bounding area for the cursor

    I need to limit cursor movement using a circular bounding area.

    Pixelthief: "using polar coordinates would be a good way to do it. Check the distance of the mouse against the center of the circle, and if its larger, find the angle to the center of the cirle, and set it to the maximum distance from the circle * the cosine/sin of that angle"

    Where do I start?

  2. #2
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleSWF Export ModuleUnicode Add-on
    Looki's Avatar
    Join Date
    Aug 2006
    Location
    Karlsruhe, Germany
    Posts
    3,741
    Mentioned
    5 Post(s)
    Tagged
    1 Thread(s)

    Re: Creating a circular bounding area for the cursor

    I'll give you the mathematic stuff.

    Code:
    | Always
    | * Set Distance to Sqr((CenterX-CursorX) pow 2 + (CenterY-CursorY) pow 2)
    | Distance > MaxDistance ?
    | * Set Angle to Atan2(CenterY-CursorY,CenterX-CursorX)
    | * Set CursorX to CenterX+cos(Angle)*MaxDistance
    | * Set CursorY to CenterY-sin(Angle)*MaxDistance
    Distance, Angle etc. are just variables that could be stored using Global Values, Counters or whatever.

    If the angle is wrong, experiment a bit. I'm not sure if it's "-sin" or "+sin" - I haven't tested the code.

  3. #3
    Clicker Fusion 2.5 Developer

    Join Date
    Jul 2008
    Location
    UK
    Posts
    1,393
    Mentioned
    16 Post(s)
    Tagged
    0 Thread(s)

    Re: Creating a circular bounding area for the cursor

    I'd use vectors rather than trig, but it doesn't make a lot of difference either way.

    + Always
    -> Set Distance to Sqr(((XMouse - XCircle) pow 2) + ((YMouse - YCircle) pow 2))

    + Distance > CircleRadius
    -> Set CursorX to XCircle + ((XMouse - XCircle) * CircleRadius / Distance)
    -> Set CursorY to YCircle + ((YMouse - YCircle) * CircleRadius / Distance)

    + Distance <= CircleRadius
    -> Set CursorX to MouseX
    -> Set CursorY to MouseY

    Instead of using an extension to move the mouse cursor, it's better to just hide the cursor, and use an active object instead.

  4. #4
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleSWF Export ModuleUnicode Add-on
    Looki's Avatar
    Join Date
    Aug 2006
    Location
    Karlsruhe, Germany
    Posts
    3,741
    Mentioned
    5 Post(s)
    Tagged
    1 Thread(s)

    Re: Creating a circular bounding area for the cursor

    Vectors, man. They do magic. I really got to get into them. That code is pretty simple but still, I never would have used something like that. Seems clever.

  5. #5
    Clicker Multimedia Fusion 2 DeveloperAndroid Export Module

    Join Date
    May 2010
    Posts
    163
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Creating a circular bounding area for the cursor

    So what is "Distance"?, and where do I put all this math? And what is XCircle and YCircle? and Where do I put Circle Radius? Are all of these just alterable values? If so, I can't name an alterable value "distance" because it is apparently a reserved expression.

    I get the math, but how do I do this in Fusion?

  6. #6
    Clicker Fusion 2.5 Developer

    Join Date
    Jul 2008
    Location
    UK
    Posts
    1,393
    Mentioned
    16 Post(s)
    Tagged
    0 Thread(s)

    Re: Creating a circular bounding area for the cursor

    Example:
    http://cid-b1e7ee094271bbda.office.live.com/self.aspx/Public/mouselimit.mfa


    "Distance" is just a temporary variable. Personally, I'd use an active object as a custom mouse cursor, and I'd make "Distance" one of its alterable values.
    Alternatively, use a global value, counter, or whatever (it doesn't much matter).
    The name is not important - call it "D" or "Dist" or whatever else you like.

    "XCircle" and "YCircle" are the X and Y coordinates of a point at the center of the circle. I don't know exactly what you're trying to do, but I'd imagine the circle is probably centered on another object - in which case, you'd just use the X and Y position of that object.
    Alternatively, use an alterable value, global value, or whatever (it doesn't much matter).

    Assuming the radius is fixed, you can just replace the words "CircleRadius" with the actual value.
    Alternatively, use an alterable value, global value, or whatever (it doesn't much matter).

Similar Threads

  1. area and cursor mouse
    By ptiseigneur in forum Multimedia Fusion 2 - Technical Support
    Replies: 4
    Last Post: 1st November 2013, 05:50 PM
  2. Circular lifebar
    By Blackwolfdave in forum Multimedia Fusion 2 - Technical Support
    Replies: 1
    Last Post: 7th August 2012, 05:40 AM
  3. Bounding Box and Resizer
    By Novabrain in forum Extension Developers Lobby
    Replies: 16
    Last Post: 24th January 2008, 04:44 PM
  4. cursor object? or own cursor?
    By Gibbon in forum Multimedia Fusion 2 - Technical Support
    Replies: 5
    Last Post: 31st December 2007, 07:52 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •