A Flash Developer Resource Site

Results 1 to 10 of 10

Thread: [MX04]Code not firing when comparing two _x positions

Threaded View

  1. #1
    Senior Member pup100's Avatar
    Join Date
    Oct 2004
    Location
    Close
    Posts
    575

    [MX04]Code not firing when comparing two _x positions

    Hi,

    Just for a bit of practice i have developed this simple game where you dynamically add sections of track to a movie & then get a ball to move down them.

    It all works great, but I was having a bit of a problem getting the ball to move along the center of a track when it went from say a straight to a vertical piece of track, as I was using hitTest to detect a collision & that was firing when the ball hit the edge of a track & not the center causing the ball to run along the outside of the track.


    To get round this I used this simple piece of code:

    code:
    if (holdNum == 2) {
    trace(xFactor);
    if (_root.ballOne._x>=xFactor) {
    xSpeed = 0;
    ySpeed = -2;
    }



    Which basically tests the tracks _x position against that of the ball & acts accordingly. "holdNum" tells Flash what type of section it is eg. straight or vertical - problem is that it does not fire?

    Anyone any ideas

    Thank you

    fla attached
    Last edited by pup100; 09-22-2008 at 12:08 AM.
    You will know everything when you know you never will.

Posting Permissions

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




Click Here to Expand Forum to Full Width

HTML5 Development Center