A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: xscale and hittest

  1. #1
    Senior Member TheLostGuru's Avatar
    Join Date
    Aug 2004
    Location
    I live on this webpage...
    Posts
    784

    xscale and hittest

    Having a little bit of trouble getting a hittest to work correctly. In my game, guys pop up and you try to shoot at them. Each guy has 3 parts, his head, his body, and his legs, which each give the player a different amount of points. To work with this, I made three transparent movieclips inside of each baddy and gave them the names, head, body, legs, respectively. This works perfectly. However, one of the locations the baddies appear in is behind a building. It's scale is decreased to 30 and the baddies parent mc has a motion tween, which makes the baddy up and over the top of the building. It is during this slide, that everything goes screwy. It appears that the hittest doesn't come along for the slide, but the graphics do (I made the graphics non-transparent to test this), so that in order to hit the baddy, I have to shoot 50 pixels beneath him. Anybody know of a problem between shape hitTest and scaling or tweening?
    "If I have seen further it is by standing on the shoulders of giants." Isaac Newton
    ------------------------------------------------------------------------------

  2. #2
    Senior Member AzraelKans's Avatar
    Join Date
    May 2002
    Location
    Hell... with frequent access to heaven ;)
    Posts
    409
    well Im doing something like that now, and hmm.. no there doesnt seem to be a problem between scaling and checking a hittest.

    If you are having trouble with hittest just create a non animated movieclip with a rectangle filled with an alpha=0 color (fully transparent), place it on the area you want the collision, INSIDE THE animated CLIP in a new layer and then name that instance "bullseye" or something now you can check the hit against that.

    If your collision was

    enemy.hitTest(myHero)

    it would now be

    enemy.hitTest(myHero.bullseye)

    you can also add one to enemies too.

    enemy.bullseye.hitTest(myHero.bullseye)

    Of course Flash can get screwy results checking shape hittest on animated clips

    Sorry about not being more explanative on that.
    Last edited by AzraelKans; 09-05-2007 at 06:43 PM.

  3. #3
    ism BlinkOk's Avatar
    Join Date
    Aug 2001
    Location
    , location, location
    Posts
    5,002
    it sounds like the center of the mc is not the center of the hit area/graphics and scaling is causing the hit area and graphics to skew away from each other.
    if you could post a pic of the game with the center of the clip marked and the hit area visible then that would help a lot.
    Graphics Attract, Motion Engages, Gameplay Addicts
    XP Pro | P4 2.8Ghz | 2Gb | 80Gb,40Gb | 128Mb DDR ATI Radeon 9800 Pro

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