A Flash Developer Resource Site

Results 1 to 18 of 18

Thread: Help again...

  1. #1
    Making an RPG
    Join Date
    Jun 2005
    Posts
    31

    Help again...

    i tried to make my "man" stop when he hits something but it won't work...

    here my code

    onClipEvent (load) {
    if(_root.man.hitTest ((this){
    stop();
    }
    }

    help please

  2. #2
    Making an RPG
    Join Date
    Jun 2005
    Posts
    31
    somoen?

  3. #3
    Making an RPG
    Join Date
    Jun 2005
    Posts
    31
    i guess noneone whats to help mme

  4. #4
    Registered User
    Join Date
    Aug 2002
    Posts
    61
    the problem is that your question is too vague, from the looks of the code you posted it doesnt work becasue 'this' has no obvious meaning.. what is 'this' what piece of material does it equate to in the movie, is 'this' a wall, another object...

    there are aot of hit detection tutorials here on flash kit and in the flash help files. tool arround in there and i think you may find what you are looking for.

  5. #5
    Making an RPG
    Join Date
    Jun 2005
    Posts
    31
    "this" is a wall

  6. #6
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141
    onClipEvent (enterFrame) {
    if (this.hitTest(_root.man)) {
    stop();
    }
    }

    Assuming there is a timeline playing inside _root.wall. This is what the 'stop()' action will do, stop the playhead running inside _root.wall. If you meant for something else to happen, you should explain.

    gparis

  7. #7
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141
    Quote Originally Posted by 3vobob
    i tried to make my "man" stop when he hits something but it won't work
    Ok i just saw that. Post the code that make the "man" walk.

    gparis

  8. #8
    Making an RPG
    Join Date
    Jun 2005
    Posts
    31
    k here the code to make the man walk


    Code:
     onClipEvent (load){movespeed = 0;
    }
    onClipEvent (enterFrame) {
     if (Key.isDown(Key.RIGHT)) {
     play();
     _rotation = 90;
     _x+= movespeed;
     }
     if (Key.isDown(Key.LEFT)) {
     play();
     _rotation = 270;
     _x-= movespeed;
     }
     if (Key.isDown(Key.UP)) {
     play();
     _rotation = 0;
     _y-= movespeed;
     }
     if (Key.isDown(Key.DOWN)) {
     play();
     _rotation = 180;
     _y+= movespeed;
     }
     if (Key.isDown(Key.RIGHT) && Key.isDown(Key.UP)) {
     _rotation = 45;
     }
     if (Key.isDown(Key.LEFT) && Key.isDown(Key.UP)) {
     _rotation = 315;
     }
     if (Key.isDown(Key.RIGHT) && Key.isDown(Key.DOWN)) {
     _rotation = 135;
     }
     if (Key.isDown(Key.LEFT) && Key.isDown(Key.DOWN)) {
     _rotation = 225;
     }
    }

  9. #9
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141
    with the variable movespeed = 0, i doubt the object moves. So when the hitTest happens, just set that var to 0.


    gparis

  10. #10
    Making an RPG
    Join Date
    Jun 2005
    Posts
    31
    the background moves it's like in stick rpg... my character satys in the middle while the background moves

  11. #11
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141
    so you want what to happen when man hits wall? the background stops moving? or the man animation stops playing?
    Also, where is that wall? is it in the background movieclip?

    gparis

  12. #12
    Making an RPG
    Join Date
    Jun 2005
    Posts
    31
    ya it's in the background movieclip and ya thats the effect i want the background to stop playing... and than we i get way from the wall the animation keeps on playing...

  13. #13
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141
    So post the code of the moving background, because it's that code that'll need to be altered.

    gparis

  14. #14
    Making an RPG
    Join Date
    Jun 2005
    Posts
    31
    k here the code fot the background...


    Code:
    onClipEvent (load) {
    movespeed = 6;
    }
    onClipEvent (enterFrame) {
     if (Key.isDown(Key.RIGHT)) {
     _x-= movespeed;
     }
     if (Key.isDown(Key.LEFT)) {
     _x+= movespeed;
     }
     if (Key.isDown(Key.UP)) {
     _y+= movespeed;
     }
     if (Key.isDown(Key.DOWN)) {
     _y-= movespeed;
     }
     }

  15. #15
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141
    on the wall:
    onClipEvent (enterFrame) {
    if (this.hitTest(_root.man)) {
    _parent.movespeed=0;
    } else {
    _parent.movespeed=6;
    }
    }

    gparis

  16. #16
    Making an RPG
    Join Date
    Jun 2005
    Posts
    31
    hey dude that didn't work... i tried changing stuff but still won't work... i think it's because you ment the parent (man) speed quale to 6... anywya it won't work... well he goes to the wall and stops when he hits it but after that he won't move

  17. #17
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141
    The _parent of wall is, from what i understood, the background.

    gparis

  18. #18
    Making an RPG
    Join Date
    Jun 2005
    Posts
    31
    ?? if you want me to show you want it does pm me

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