The forums have permanently moved to forum.kirupa.com. This forum will be kept around in read-only mode for archival purposes. To learn how to continue using your existing account on the new forums, check out this thread.


Results 1 to 3 of 3

Thread: Pushing a movieclip around / collision detection ++

  1. #1

    Rotating a MovieClip ++

    Hi,

    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.xspeed=-1;
    this.yspeed=0.25;


    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
    Code:
    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

 Credits

Copyright 1999 - 2012