A Flash Developer Resource Site

Results 1 to 9 of 9

Thread: help with a game

  1. #1
    FIRE!
    Join Date
    Aug 2002
    Posts
    29

    help with a game

    I'm having troble with a little game i am making. You drop bombs and the ground gets blasted away. This is what happens..

    A movie clip is duplicated and accelerates downward. when it contacts the ground it goes to a different frame with a black color (the same as the background) and stops. This gives the effect of the ground being blasted away (like worms). The problem i have is when the bomb hits the ground the others need to test the ones that have blasted the ground away and therefore travel through them as well. I used a loop to detect the ones on the ground already, but i cant figure out how to make them pass through the others smoothly.

    go Here to see the swf.

  2. #2
    Senior Member
    Join Date
    Jul 2000
    Posts
    5,087
    Instead of switching the MC to show black you could just remove it assuming that the background is black.

    the Action to do that is RemoveMovieClip().

  3. #3
    FIRE!
    Join Date
    Aug 2002
    Posts
    29
    If i remove it though, then it dosn't appear that the ground is being blasted away.

  4. #4
    Senior Member
    Join Date
    Jul 2000
    Posts
    5,087
    You could compose the ground of multiple overlaping MC's that way one one is removed it leaves a whole.

    Other than removing the clip how are you using Hit Test? You could do this in several ways. One way is to use a Var in each MC. The bomb checks fore the Value. If the Value is true it turns black and removes the bomb. Once it is flagged true change it to so that it no longer flags true.

    Another way is to check for the Hit test using a Frame. The use Goto and Stop Frame without the Hitest for the ground.

  5. #5
    FIRE!
    Join Date
    Aug 2002
    Posts
    29
    heres the code for the bomb mc:

    onclipevent (load){
    this.gotoandstop(1);
    yvel=0;
    inc=.4;
    rand=math.ceil (math.random() *4);
    cc=_root.c; //just finding out the # of this mc so i dont collision
    } //detect for itself later



    onclipevent (enterframe){
    if (_y>412){removemovieclip();} // mc falls too far and gets deleted
    yvel+=inc;
    _y+=yvel;




    if (_root.ground.hittest(_x,_y,true)){ //mc hits ground


    yvel=0; //velocity and the number it is
    inc=0; //increased by is set to 0
    if (rand==1){this.gotoandstop(2);} // random black craters
    if (rand==2){this.gotoandstop(3);}
    if (rand==3){this.gotoandstop(4);}
    if (rand==4){this.gotoandstop(5);}
    } else {

    for (i=0 ; i<cc ; i++){ //testing for a collision with
    if (i==cc){i=i+1;} //other mcs already stoped at ground
    if (hittest(_root["mc"+i])){
    this.gotoandstop(1); //this is where i need help <--
    yvel+=inc; // <-- if it collides with other mcs,
    _y+=yvel; // <--ignore vel set to 0
    } // but when it collides with multiple
    } // the vel gets doubled each time
    }



    }

  6. #6
    Senior Member
    Join Date
    Jul 2000
    Posts
    5,087
    Simple fix here.

    take this;

    if (_root.ground.hittest(_x,_y,true)){ //mc hits ground


    yvel=0; //velocity and the number it is
    inc=0; //increased by is set to 0
    if (rand==1){this.gotoandstop(2);} // random black craters
    if (rand==2){this.gotoandstop(3);}
    if (rand==3){this.gotoandstop(4);}
    if (rand==4){this.gotoandstop(5);}
    } else {

    for (i=0 ; i<cc ; i++){ //testing for a collision with
    if (i==cc){i=i+1;} //other mcs already stoped at ground
    if (hittest(_root["mc"+i])){
    this.gotoandstop(1); //this is where i need help <--
    yvel+=inc; // <-- if it collides with other mcs,
    _y+=yvel; // <--ignore vel set to 0
    } // but when it collides with multiple
    } // the vel gets doubled each time
    }


    from the onclip event. Create 2 frames with 0 tweens. Add them to the first frame and add a gotoand Play frame back to the frame with your action. You will also have to shift your MC. What that will do is make it so that the Random Black chunk will not execute a hit test and your bomb should pass through.

  7. #7
    FIRE!
    Join Date
    Aug 2002
    Posts
    29
    ahh, good idea. I'll try it now.

  8. #8
    FIRE!
    Join Date
    Aug 2002
    Posts
    29
    came across somthing else.

    if (_root.ground.hittest(_x,_y,true)){ //mc hits ground


    yvel=0; //velocity and the number it is
    inc=0; //increased by is set to 0



    if the bomb hits the ground. even when the bomb is passing through the black mcs these properties are still being applied.

  9. #9
    Senior Member
    Join Date
    Jul 2000
    Posts
    5,087
    As you are removing the bomb if it hits a section of ground it would not need to have its velocity set to 0 as its gone.

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