SITE MOVING

NEW WEBSITE, I've moved everything to a new site. Its not just a blog anymore, its a full blown website.

REPEATE!: its not over just moving!

THE WEBSITE IS:
www.bxstudios.weebly.com

CHECK IT OUT FOR LOTS MORE TUTORIALS!

Welcome To Max's Flash Tutorials!

Here I will eventually post everything I know about flash. That ALOT! I am currently working on one of the best and far most interactive games I've ever made. Its called, "The Burbz RPG" and it will release some time in the summer of 08. That takes up a lot of my time but after I release the game on to the internet I will have a lot more time to write up tutorials.

Sections

Sunday, January 13, 2008

Use Hit Test To Make Walls

Here I'll show you how to use hit test to make a wall in your flash game/movie. First you should probably have your character move so he/she can actually hit the wall. A hit test tells flash what to do once to objects have touched/collided. Like a man and a wall for instance.

If you haven't already viewed the following tutorial I suggest you do.
8 Way Movement Tutorial
  1. First make sure you gave your charector the instance name of "man"
  2. Then draw your wall (can just be a line if you want)
  3. Select your wall
  4. Hit "F8"
  5. Name your wall and select "Movieclip"
  6. Then click "OK"
  7. Now skip to the Action Scripting Section below

You will have to put a different action script based on the way your charector will be hitting the wall (from what side). He can hit it from the top, the bottom, the left, or the right. Choose below and add the opproperiate Action Script.

Hit From Above:

  • onClipEvent (enterFrame) {
  • if (this.hitTest(_root.man)) {
  • _root.map._y -=5;
  • }
  • }

Hit From Below:

  • onClipEvent (enterFrame) {
  • if (this.hitTest(_root.man)) {
  • _root.map._y +=5;
  • }
  • }

Hit From Left:

  • onClipEvent (enterFrame) {
  • if (this.hitTest(_root.man)) {
  • _root.map._x +=5;
  • }
  • }

Hit From Right:

  • onClipEvent (enterFrame) {
  • if (this.hitTest(_root.man)) {
  • _root.map._y -=5;
  • }
  • }

Thats It, Now Test Your Game/Movie!

Please let me know how this went for you...

7 comments:

POw said...

Just a correction...
In the code of the wall
the code are root the map objet,
this word have to be the instance name of the player, in this case "man".

ex:
onClipEvent (enterFrame) {
if (this.hitTest(_root.man)) {
_root.man._y -= 5;
}
}

Max said...

well, yes you would do that if u wanted to have the player move around the screen, but this way makes the map or background move while your player apears to be moveing. Either way is fine, but in the way that was posted you can have bigger maps.

Temporal said...
This comment has been removed by the author.
lpb50 said...

it didnt work for me i put all the scripts in and made my man jump hoping he'd hit it and fall back down but he just went through it have i done something rong??

Spuddy - a.k.a the ARKane potato said...

Thanks, that helped HEAPS. I've been trying to get a hitTest that works for a couple of days now, Thanks!

Kevin said...

Worked great. Thanks a lot. Now my Pac Man game works.

sea said...

My guy just went through, hit the ground and then rose up to the platform until he was ._y-=5; from the platform... how can i make it so when he touches the platform he stops?