A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: check for hit test while object passes over another

  1. #1
    Junior Member
    Join Date
    Aug 2016
    Posts
    11

    check for hit test while object passes over another

    Hi all, I am creating a simple game in Animate. I want to be able to pick up(drag and drop) a MovieClip(1) which when moved over another MoviClip(2) will change the opacity of the topmost layer in MovieClip(2). I know I do not explain well.

    The game will involve washing dishes or a car. As a graphic of a 'sponge'(clip-1) is moved over a representation of dirty dishes or a dirty car-bubbles animate from the 'sponge' and depending on how long the 'sponge' is held over the dishes(2) then the opacity of the top layer (which will represent dirt) will drop to reveal a 'clean' layer beneath.

    I have seen this exact thing done in the app my boo where the creature is washed with a sponge.
    myBoo.jpg

    I have a MovieClip1(sponge) and MovieClip2(dishes). I have used the Touch_begin and Touch_end events so I can drag MovieClip1 around the screen. I stored it's original position so when I let go it returns to it's original point. Works great.

    I need for MoviClip1 to check whether it has passed over MovieClip2.

    I have tried placing HitTest in both the Touch_begin and Touch_end functions and run a trace. My MovieClip1 only checks for a hit test when I first drag the movieClip or when I drop it, registering no collision.


    Is there a way of getting movieClip1 to check for a HitTest as it passes over movieClip2.


    Thanks in advance
    Peace
    John


    Return to posts index

  2. #2
    Mod cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    You can try to put the hittest into a setinterval function, which is active, when the object is moved.
    - The right of the People to create Flash movies shall not be infringed. -

  3. #3
    Senior Member realMakc's Avatar
    Join Date
    Oct 2002
    Posts
    921
    who is this? a word of friendly advice: FFS stop using AS2

  4. #4
    Junior Member
    Join Date
    Aug 2016
    Posts
    11
    Thanks cancerinform. Doesnt work for me. Thanks for the interest and help.

  5. #5
    Junior Member
    Join Date
    Aug 2016
    Posts
    11
    RealMakc should I create TOUCH_MOVE function sandwiched between TOUCH_BEGIN and TOUCH_END?

    I am a serious newby and trying to get some code together for very basic interactivity. Thanks for your interest.

  6. #6
    Junior Member
    Join Date
    Aug 2016
    Posts
    11
    Edit: I dont explain well.

    Should I create a new TOUCH_MOVE function with hit test and setinterval inside of it?

  7. #7
    Junior Member
    Join Date
    Aug 2016
    Posts
    11
    Hi guys, I have been looking into this.

    How can I create a TouchBegin which contains a hitTestObject in a loop while dragging and terminate the loop when dragging stops.
    or as cancerinform suggested:
    put the hittest into a setinterval function, which is active, when the object is moved.

    help is much appreciated guys.

  8. #8
    Senior Member realMakc's Avatar
    Join Date
    Oct 2002
    Posts
    921
    Quote Originally Posted by ransome View Post
    Edit: I dont explain well.

    Should I create a new TOUCH_MOVE function with hit test and setinterval inside of it?
    I think I mean you use touchMove handler instead of setInterval.
    who is this? a word of friendly advice: FFS stop using AS2

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