A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Collision with two objects

  1. #1
    Always needs help marinebro0306's Avatar
    Join Date
    Jul 2005
    Location
    Philadelphia
    Posts
    166

    Collision with two target objects

    I'm very new to 3DFA, and I know how to do collision. But, how do I do collision between 1 thing I am controlling and two things I want to avoid? The thing I am controlling is called circle, and the two others are square and square2.
    My script:
    if (circle.collideRect (square || square2)){
    loser.show()
    }
    if (!(circle.collideRect (square || square2))){
    loser.hide()
    }

    Loser is the message.
    Help please!
    Last edited by marinebro0306; 07-26-2005 at 10:07 PM.

  2. #2
    Senior Member
    Join Date
    May 2005
    Posts
    163
    From what you described it sounds like all you want to do is:

    if (circle.collideRect (square) || circle.collideRect (square2)){
    loser.show()
    }else{
    loser.hide()
    }

    Assuming that element loser is already hidden I would even skip the "else" part of this statement.

  3. #3
    KoolMoves Moderator blanius's Avatar
    Join Date
    Jul 2001
    Location
    Atlanta GA
    Posts
    5,244
    Almost because if you collide and want the message to re-hide when they no longer collide you do need it.

  4. #4
    Senior Member
    Join Date
    May 2005
    Posts
    163
    Yes, makes sense when you put it that way.

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