Everybody! This is important. In a few days, these forums will be moving over to using the totally sweet Discourse platform. To ensure this migration happens smoothly with no loss of content, these forums are currently in a read-only mode. I do apologize for the inconvenience.

There is never a good time to turn the forums off for an extended period of time, but I promise the new forums will be a billion times better. I'm pretty sure of it.

See you all on the other side in a few days, and if you have any (non-technical) questions, please e-mail me at kirupa@kirupa.com. For technical questions, try to find a tutorial that corresponds to what you are looking for and post in the comments section of that page.


Results 1 to 3 of 3

Thread: Pushing a movieclip around / collision detection ++

  1. #1

    Rotating a MovieClip ++


    So, I'm working on a banner which will be using a lot of techniques usually used in games, such as collision detection and user interaction to change the direction and of a movieclip.

    I have a movieclip on the scene that starts out moving around the screen at a certain x and y speed:

    This movieclip is reflected back when it hits the edges of the scene (xspeed or yspeed is reversed). Lets say that when the movieclip hits the right edge of the scene and is reflected, I also want it to rotate +30 degrees. However, if has already been rotated 30 degrees and hits that same right edge again, it should rotate back to the original angle.
    Any thoughts on how to accomplish this?

    Also, beneath that main movieclip is a shadow. This shadow should shrink or grow and decrease or increase its alpha-value, depending on the y-coordinate of the main movieclip (or distance between the shadow and the main movieclip).
    How would I best deal with this situation?
    Last edited by maaartin; June 1st, 2008 at 02:05 PM. Reason: old problem solved, new ones come up

  2. #2
    var xspeed:Number = 5;
    var yspeed:Number = 0.025;
    //set square to wall1 position (hitTest them to start it up)
    square._x = wall1._x; 
    onEnterFrame = function ()
        if (square.hitTest(wall1))
            square._rotation = 0;
            square.onEnterFrame = function () 
                this._x += xspeed;
                this._y -= yspeed;
        if (square.hitTest(wall2))
            square._rotation = 30;
            square.onEnterFrame = function () 
                this._x -= xspeed;
                this._y += yspeed;
    Okay I posted something before but the idea it turned out was convoluted so I ended up doing a simple hitTest to make the movieClip go back and forth.

    I made 3 movieClips, square is the one that moves around. Wall 1 is left border, wall 2 is right border.

    I'll figure out the other parts and let you know. There may be a better way to do this stuff so someone else should pipe up.

    *** Oh **** woops, I didn't notice that you had solved your problem =/
    Last edited by t0w; June 2nd, 2008 at 02:57 PM.

  3. #3
    I figured it out in the end, but thanks for your input.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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

Home About kirupa.com Meet the Moderators Advertise

 Link to Us


Copyright 1999 - 2012