• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 242
  • Last Modified:

MC follows mouse question

Hi, Experts

I would like to make the MC follow the mouse. However, it is not really working.... The 1st layer MC instance name is "allMC" and there is another movie clip inside "allMC" called "fighter".... I want to control the "fighter" inside the "allMC". Thanks

--------------------  CODE  ---------------------

allMC.fighter._x = allMC.Stage.width/2;
allMC.fighter._y = allMC.Stage.height/2;
var myConstant = 5;
_root.onEnterFrame = function() {
      var destinationX = _root._xmouse/6;
      var destinationY = _root._ymouse/6;
      inertiaX = (destinationX-allMC.fighter._x)/myConstant;
      inertiaY = (destinationY-allMC.fighter._y)/myConstant;
      allMC.fighter._x += inertiaX;
      allMC.fighter._y += inertiaY;
      //fighter._xscale += inertiaX;
      //fighter._yscale += inertiaY;
      if (_xmouse<5 || _xmouse>295 || _ymouse<5 || _ymouse>245) {
            allMC.fighter._x = allMC.Stage.width/2;
            allMC.fighter._y = allMC.Stage.height/2;
      }
};
----------------------------------------------------------------
0
Brian Lin
Asked:
Brian Lin
  • 2
1 Solution
 
FLAASHERCommented:
its work with me ..... its move the same direction as mouse

what kind of moving u want exactly ???



FLAASHER
0
 
Brian LinDesignerAuthor Commented:
Hi, Flaasher

Thanks for the reply....here is the fla file and please take a look

http://www.4shared.com/file/6551562/d63677fa/dropBomGame2.html

Thanks
0
 
FLAASHERCommented:
allMC._x = Stage.width/2;
allMC._y = Stage.height/2;
var myConstant = 5;
_root.onEnterFrame = function() {
      var destinationX = _root._xmouse/1;
      var destinationY = _root._ymouse/1;
      inertiaX = (destinationX-allMC._x)/myConstant;
      inertiaY = (destinationY-allMC._y)/myConstant;
      allMC._x += inertiaX;
      allMC._y += inertiaY;
      //fighter._xscale += inertiaX;
      //fighter._yscale += inertiaY;
      if (_xmouse<5 || _xmouse>295 || _ymouse<5 || _ymouse>245) {
            allMC._x = Stage.width/2;
            allMC._y = Stage.height/2;
      }
};
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now