Fork me on GitHub
Not signed in (Sign In)

Welcome, Guest

Want to take part in these discussions? Sign in if you have an account, or apply for one below

    • CommentAuthormp
    • CommentTimeOct 27th 2008 edited
     
    hi!
    i need some help...i'm trying to put the particles, moving to the mouse position.
    for now i've a setTimeout function that checks every second the mouse position, and if i click in the stage, i want that particles 'fall down'.

    before declaring that the particles should follow the mouse position, i had random positions and at some way the particles were moving to the indicated positions.
    but now the particles aren't moving to the mouse position...After the particles collide the first time against the bounding box, they stay at that position.

    here is some part of my code:

    //
    stage.addEventListener(MouseEvent.CLICK, stopMouse);

    var myTimer:Timer = new Timer(1000);
    myTimer.addEventListener('timer', moveMouse);

    function moveMouse (evt:TimerEvent):void
    {
    emitter.addAction( new Accelerate( mouseX,mouseY));
    }

    function stopMouse(evt:MouseEvent):void
    {
    myTimer.removeEventListener('timer', moveMouse);
    emitter.addAction( new Accelerate( 0,10) );
    }
    myTimer.start();


    thanks
    mp
    • CommentAuthorRichard
    • CommentTimeOct 30th 2008
     
    Accelerate( mouseX, mouseY ) won't cause the particles to move towards the mouse unless they are at or near the origin. You need to accelerate them in the direction mouseX - particle.x, mouseY - particle.y. You may want to try the TurnTowardsMouse or the MouseGravity actions instead.