Follower of the mouse of rotation with easing

I'm terrible at math and having a problem to reach my goal.

http://www.newgrounds.com/dump/item/6e5cde6c6b94de74119aac82c43312d2 - example

It works just fine, but what I want to do is have each object to follow the rotation at different speeds. I want that every MC having "Acceleration".

I can't understand how to run a little slower than the mouse itself. As a result, just dead on, same speed as the mouse moves, it moves.

Related to mcMouseFollower.as MovieClip class.

I have my main class the following:

package {}

import flash.display. *;

import flash.events.Event;

SerializableAttribute public class MAIN extends MovieClip {}

public var follower: mcMouseFollower;

public void MAIN () {}

the constructor code

Tracker = new mcMouseFollower();

Follower.x = stage.stageWidth / 2;

Follower.y = stage.stageHeight / 2;

stage.addChild (follower);

stage.addEventListener (Event.ENTER_FRAME, frameLoop);

}

public function frameLoop (event: Event): void {}

Check out the coordinates of the mouse to discover the angle

var cy:Number = stage.mouseY - follower.y;

var cx:Number = stage.mouseX - follower.x;

var Radians: Number = Math.atan2 (cx, cy); / / Find the angle

var degrees: Number = Radians * 180 / Math.PI;// convert to degrees of rotation

Rotate

Follower.rotation = degrees;

}

}

}

To do this manually, you need to find the change in rotation between the follower.rotation and the degrees of calculated. Then, you apply some of this difference. So if you want to have the rotation of the rod move 1/10 of the path to the destination of your choice each image, calculate the change in the rotation needed to point to the mouse, then multiply by 0.1 and apply this rotation changed to follower.rotation. This does not exactly work as tweens that you configure in Flash because it will not have an exact end time. Instead, each image rotation reduces the difference in new rotation of half. It will resemble an ease of exit. You can check when it is thin enough (for example, the difference is less than 1 degree) and just snap to your final rotation rather than continue to settle for halfway.

You'll want to know how to work the degrees of rotation. Pointing to the right is 0 degrees, rotation to the right there is positive, go to 180 that points to the left. From 0 degrees and rotating timer causes the downward rotation value, entering negative numbers, from 0 to-180 (pointing to the left). So when you try to interpolate a value through the left direction you have a problem, since the numbers of jump from-180 to 180 at that time here.

To solve this * West * problem, you detect if the rotation must be changed by more than 180 and you adjust accordingly for the direction of rotation moves the shortest distance to the rotation of the target rather than the long way around. The calculation in the SmartRotationPlugin of the packaging of GTween is a good way to handle this:

https://code.Google.com/p/Pipoca/source/browse/trunk/classes/com/gskinner/motion/plugins/S martRotationPlugin.as? r = 9

Here's the corrected code (starting after your calculation of degrees):

var deltaDegrees:Number = degrees - follower.rotation;

deltaDegrees % = 360;

If (deltaDegrees > 180)

{

deltaDegrees-= 360;

}

ElseIf (deltaDegrees<>

{

deltaDegrees += 360;

}

Rotate

Follower.rotation = degrees;

Follower.rotation += deltaDegrees * 0.1;

You can also consider using a tween as GTween for your tween engine: http://www.gskinner.com/libraries/gtween/

Tags: Adobe Animate

Similar Questions

  • follower of the mouse in the specific area?

    I don't know if I can explain it clearly enough because I'm not familiar with all the terms, but I'll try.

    I created a flash to act as a counter banner. The logo of "brain" must go up and down the thermometer mercury according to the placement of the mouse on the text one long side of the banner.

    Right now I have the logo of "brain", defined as an interpolation in this area; However, this is not what I want. I'm also a follower of the "brain" logo which is useless I did only try to understand such things.

    If someone could please point me in the right direction, I would really appreciate it.

    For an idea of what I'm talking about the flash banner can be found here.
    Remember, it's only a concept right now.

    Thank you.

    Thank you once again, but I found the answer I was looking for somewhere else.

    ActionScript for disciple online right, top and bottom of line-

    var speed: Number = 5;
    function follow() {}
    this.onEnterFrame = function() {}
    Brain._y += (_ymouse - brain._y) / speed;
    If (Math.abs(_ymouse-brain._y)<1)>
    dot._y = _ymouse;
    delete this.onEnterFrame;
    trace ("Middle");
    }
    If (dot._y > line._y + line._height) {}
    dot._y = line._y + line._height;
    delete this.onEnterFrame;
    trace ("bottom");
    }
    If (brain._y
    Brain._y = line._y;
    delete this.onEnterFrame;
    trace ("Top");
    }
    };
    }
    onMouseMove = function () {}
    Follow();
    };

  • Cannot not left/right, click anywhere for 1-3 seconds after moving the mouse to even. The mouse works fine with all other programs.

    Moving the mouse to any results on the ground in time. For example: when I moved the mouse to the "Détails" box, it was entirely 2 seconds before I saw an indication that I could enter data. What reading mail on Yahoo, if I want to mark an item to move, delete etc. I find the mouse cursor on the box for 1-3 seconds before I can click on the box. The problem occurs no matter wherever the cursor of the mouse is used. (Switch from one tab to another, ranging from one matter of Facebook to another, everywhere!) I should point out that I tried to run my Email, Facebook and all regular applications with Internet Explorer and I have not had any problems at all. I uninstalled and reinstalled Firefox. No help! I like Firefox and use it for years, it's only in the last few weeks that this problem has come. I really don't want change in Chrome or IE, but I can't continue with this problem. I'm not a technology expert, so I hope that there is a pretty easy fix.
    Thanks in advance,
    Chuck

    Sorry I should have to take a look at this earlier, but you have several versions of Flash installed. Having multiple versions of the same plug-ins can cause problems.

    Take uninstaller from here:

    And install the latest version here: https://get.adobe.com/flashplayer/
    Notice that the link is usually an 'optional' offer for the McAfee toolbar in the middle pane you can untick this box as it is not necessary to use a Flash.

  • Where the mouse to use with the Y2P?

    I have a model of mouse Microsoft Optical 3902c 693. I can't make it work with my Y2P. I installed the driver of windows 8 on the Microsoft site and it still does not work. Someone knows why? And what mouse would you recommend that works with the Y2P?

    Here are the mouse:

    http://tinkernorthwest.ecrater.com/p/12964992/Microsoft-Optical-USB-mouse-3902c693

    You shouldn't need a driver installed about any mouse to have at least basic features.

    I have no idea why it wouldn't work. Have you tried both USB ports?

    It appears in Device Manager?

    Z.

  • When I select a single object in a layer and try to move it with the mouse, everything goes with...

    I had this problem where I can't use the tool move with the mouse properly. I'll go and select an item on a layer and then try to move it with the mouse (move tool). I did this before and still do all the time on Photoshop on my other machines. However, on my laptop it will not work. I take the only object I want to go and the second I move, is by default moving each layer in my folder. The only way to get around is to use the arrows, but which becomes laborious and frustrating.

    Any ideas?

    Maybe you have enabled automatic selection? There is a checkbox for it just at the top of the interface.

  • Use the mouse to rotate

    Hello. I do a RPG, and I want the character to deal with the mouse (turn then it looks the mouse). I use Flash Pro 8 and the scene is 550 X 400 pixels. Any help is appreciated. Thank you.

    Hey this will help, just copy the code have the action for the clip
    onClipEvent (mouseMove) {}
    varX = _root._xmouse - this ._x;
    Vary = - 1 *(_root._ymouse-this._y);
    angle = Math.atan2 (vary, varX);
    angle = Math.round(angle/Math.PI*180;)
    This ._rotation = - 1 * (angle);
    }

    Here's how it will look
    http://img223.imageshack.us/my.php?image=eyesge2.swf

  • The scaling and rotation with the motion tween

    This is a ridiculously easy problem but I paint a mental space to how to do this in advance I apologize for simplicity. I'm trying to get a clip to rotate and to scale automatically without be clicked. I would like that it gradually rotate 90 degrees and scale by 150%, but I can not find a way to get a motion tween, to do and am having to do it manually frame by frame. What is the code for this?

    Thank you!

    If you are using CS4 or later, make sure that you use the classic Tween to what you call, you tried. Asked only that I have, it's mention you a clip twice... If you are inside the movieclip you cannot rotate and resize it from there.  So is there a clip within the clip, and this is the internal clip you are trying to tween?  The object you to scale and rotate should be a symbol in the library.

  • follower of the mouse

    I used this script very well with flash player 5 (and may still), a long time there, but it will not work with the player 9 and I don't see what the problem with the code. Its framework on 1 and 3 of a clip.

    Frame.1
    Physics = [0.25,0.6]

    Frame.3
    XSpeed = ((_parent._xmouse-_x) * physics [0]) +(xspeed*physics[1]);
    _x xspeed +=;
    gotoAndPlay (2);

    It's so old school and there are probably better ways to do this now, but the easiest solution would be part 1 Add this:

    XSpeed = 0;

    Or what the original speed should be.

    I think it was in Flash 7 when you need to initialize variables before you use them. In previous versions the value of xspeed (on the right) would have missed the first time about zero, but now it just does not compute at all.

  • Bluetooth Arc touch mouse without being detected by the "mouse and keyboard Center."

    The mouse is paired with your PC via bluetooth and works very well.  (Please re-read that last sentence before you send information on how to pair.)

    However, when I open the Microsoft Mouse and keyboard Center, it says "no device detected".  For example, I can't change the settings of the mouse. There are the most annoying rattling noise that I would turn off.

    Have uninstalled Microsoft Mouse and keyboard Center, reinstalled latest version. IM using windows 7.

    Hello Frazer,

    We want to get this support, please follow the steps on how to solve Microsoft Mouse and keyboard issues:

    1. run the hardware store in Windows 7.

    2 steps on how to install the driver in compatibility mode:

    a. do the driver installation file right click and select properties and then tap or click on the Compatibility tab.
    b. check run this program in compatibility mode.

    c. press or click the menu drop down and select a previous operating system, and then tap or click OK.
    d. try to install the driver and verify.

    Let us know how it goes.

    Kind regards

  • the mouse does not work after a beep

    I currently have Windows 7 installed on my desktop at home.
    Lately I had problems with the mouse. When I start windows, it seems to work very well. After a few minutes, I hear a strange beep & the mouse no longer works in total. I tried to disconnect & reconnected again to see if there is no dust collected but that doesn't seem to work. I checked if the drivers are updated, I saw that the latest version of the driver has been installed. I checked if there is a problem with the ports. I started in safe mode. Uninstalled ports & restarted my computer. For worms, it seems to work fine, but now it seems I have the same problem again. For this reason, it is necessary to reboot the machine again & again once because the mouse freezes & I'm stuck here.

    Help, please

    Hello

    ·         The mouse works fine with other computers?

    ·         Did you make any changes before the show?

    ·         How is it connected to the computer (wired or wireless)?

    ·         What is the number and model of the mouse?

    Method 1:

    If it is connected by USB, I suggest you try to login via the different USB port and check if the problem persists.

    You can also run the hardware and devices Troubleshooter and check if it helps:

    http://Windows.Microsoft.com/en-us/Windows7/open-the-hardware-and-devices-Troubleshooter

    Method 2:

    I also suggest you to start in safe mode and check if the mouse is working properly. To start in safe mode follow the below link;

    http://Windows.Microsoft.com/en-us/Windows7/start-your-computer-in-safe-mode

    Method 3:

    If in safe mode mouse works fine, I also suggest you to place the computer in a clean boot and make sure that the third party software that is causing the problem:

    http://support.Microsoft.com/kb/929135

    Note: Make sure that when you have completed troubleshooting set the computer to a normal startup by following step 7 from the link above.

  • The mouse freezes and disappears in Windows 8

    I've seen a lot of discussions on this problem on here, but no resolution.  Each aid seems to have everyone check their settings, but I never see no follow-up, indicating that it is resolved.

    I did everything suggested, including relocation or installation of drivers more recent but less specific and eventually went back to reinstall the drivers installed initially.  That's what I see:

    I have a Toshiba laptop, P845T, with a 3.1 Microsoft desktop receiver connection model 4000 wireless keyboard and Laser Mouse 5000.

    I loaded a few pointer graphics (HAL9000) if different from the standard in order to follow when the mouse is pointing upwards and disconnect it see where are.  Here's what I see:

    When I start the computer from a stop, I almost always comes back to the standard mouse pointers.  At some point during the day, they will disappear.  The mouse is essentially functional, but difficult to use because I have to constantly use the CTRL key to know where he is.  IE10 and MS Word seem to be triggers, but I could not confirm this.

    Before or after a failure, but once restored to the default settings of the mouse, I can open the control Panel\Hardware and Sound\Mouse and get the mouse properties window.  On the "pointers" tab, I see the pattern that I have previously downloaded and saved as one asset/chosen, but I actually use the mouse in endangered or by default until I hit OK or apply.  Please note that I have not changed a thing on the window - only watched and clicked OK.

    I hope someone can tell me something I've not seen many times seen as questions on several previous posts.  I'm sure I got something wrong or do something wrong, but I'm quite frustrated.  The mouse still seems to disappear when I haven't the time to restart and reset.

    Here are some examples:

    http://answers.Microsoft.com/en-us/Windows/Forum/windows_8-hardware/Synaptics-touchpad-does-not-work-on-Windows-8/d1650eab-d4c5-44BA-8d4a-1abcfa589606

    http://answers.Microsoft.com/en-us/Windows/Forum/windows_8-hardware/mouse-settings-not-saved-after-rebootrestart/0ceb90e7-ccb7-4c78-9a6f-dbfb2721d71b

    http://www.TomsHardware.com/FAQ/ID-1656322/mouse-cursor-disappearing-laptop-Windows.html

    http://answers.Yahoo.com/question/index?QID=20130312132048AAJDHR2

    Hello

    In the face of this problem if you use the built-in touchpad drivers?

    This problem can occur if the mouse drivers are not installed properly or the drivers are not compatible with the operating system.

    You can upgrade the laptop Chipset drivers and check if that helps resolve the issue.

    Visit this link for more information about how to download and install the latest Chipset drivers.

    Toshiba support

    I hope that helps!

  • When my Mac restarted the mouse arrow moves in order to type the password

    When my Mac restarted the mouse arrow moves so I can type my password

    I guess the mouse battery is fully charged and that the mouse work? You can see if the mouse is paired with your mac?

    You can also use the arrow keys + return to select a user to connect.

  • What would cause the mouse to scroll slowly on Web pages, but normally on text documents?

    I have a strange problem. I have a Logitech M305 mouse on another machine which is too slow scrolling on Web pages. I ordered a new mouse, but today I noticed the old mouse normally scroll in text documents, even though the text document is displayed in Firefox (such as the "subject: config" page).

    Normally, a page will scroll 3 lines for each click of the mouse wheel.
    On Web pages, it changes and it takes 3 clicks of the mouse wheel to get the page to scroll.

    It is troubling to move the mouse wheel and don't have anything happen until the third click.

    So the question is, what would make the mouse wheel behave differently on the Web pages and pages of text, and how can I solve this problem?

    BTW, this is a clean install of Windows 7 64-bit. I use the same exact type of install now on another machine with a mouse Logitech M510 and normally scrolls on all pages.

    OK, a final report on this issue. Yesterday, before installing the new mouse M325, I decided to uninstall the Logitech SetPoint software. I wanted a new installation of the software for the mouse to go with the new mouse.

    To my surprise, after the set point has been uninstalled the old mouse M305 scroll normally on pages of text and Web pages. It seems that something mysterious happened in the relationship between Firefox and the original installation of set point. Firefox made some adjustments or updates of its own regarding record just as it does for modules, I saw it happen a couple of times before. /shrug

    New mouse + set works perfectly with FireFox now and the old mouse M305 + setpoint is now works well with an old laptop XP Pro, at least as long as the button pop-up gimpy holds.

    Solution, in this case: uninstall the Logitech SetPoint mouse software, and then reinstall a new copy of it.

  • the mouse position on waveform graph

    Hi all!

    Is it possible to get the data? I use graphic waveform to present data. Thin zoom I now the position of the mouse XY (best with regard to the actual scales of the plot).

    Thanks to you ALL

    One of my most used methods is the Coords XY card

  • Is it possible to set the mouse cursor in the Xcontrol?

    In my Xcontrol, I want to change "the mouse cursor. But I found, I can only change the cursor in the VI, which contains my Xcontrol.

    An example: I edited the example labview "Dual Mode thermometer. In case of change of front/data, I put the cursor 2. but it did not work?

    Here is an example to change the cursor when the user points the thermometer

    This mouse enter for the class VI of VI of façade:

    I have a similar setup for the mouse event leave with the value 1.

    Tone

Maybe you are looking for