Best viewed in Firefox

Awesty Productions

Making Walls with hitTests

September 3rd, 2006 by awesty

In this tutorial I will teach you how to make walls for you games using hitTests with actionscript.
What you need to know:

  • Basic flash skills. Like using all the tools and everything.
  • You need to have taken my ‘Moving MovieClips with the ArrowKeys tutorials. Click here veiw it now.
  • It would help if you had knowledge of another programming language like PHP, JavaScript or C++.

I am using Flash 8 for this tutorial, but you can use Flash MX 2004 if you want.

Lets begin!

Thanks for taking the time to veiw this tutorial!

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • blinkbits
  • BlinkList
  • blogmarks
  • del.icio.us
  • digg
  • Furl
  • MyShare
  • NewsVine
  • Netscape
  • Reddit
  • Simpy
  • Slashdot
  • StumbleUpon
  • Technorati
  • YahooMyWeb

RSS feed | Trackback URI

144 Comments »

Comment by Tom
2006-09-16 00:38:32

hey man, this tutorial was AWSOME :P sure ur drawings r a little crappy, but the lay out was sweet, thanks a bunch man.

 
Comment by awesty
2006-09-16 09:52:58

Glad you liked it, keep coming back and there will be heaps more soon ;)

 
Comment by neil
2006-09-17 04:14:15

Thanks for the tutorial, its getting me finaly UNDERSTANDING actionscript rather than just copying and pasting it, so that i can start to write my own. Thanks!

 
Comment by Andrew
2006-09-17 06:29:04

THANK YOU!!! I”VE BEEN LOOKIN FOR THIS 4 A WHILE!!!

 
Comment by DAVID
2006-09-18 12:24:36

HELP DOESNT WORK(MOVIE WILL NOT LOAD)SOME1 EMAIL ME DIRECTIONS PLEASE
gatemanornametag@hotmail.com

 
Comment by awesty
2006-09-18 12:27:02

send me the .fla and i will have a look at the problem ;) admin AT awestyproductions DOT com

 
Comment by DAVID
2006-09-18 12:29:05

no its that the movie on da…Um site dont load up T_T

 
Comment by awesty
2006-09-22 14:23:27

Have you got the latest flash player?

You can download it here:
Click here

 
Comment by fitskies
2006-09-23 12:43:54

(My name is not fitskies in real life) I spent 2 hours carefuly puting in the action scripting and when i tried it the character just walks trough the wall apart from the one on the left the character just slides out of the box >:(

Comment by Shreve19 Subscribed to comments via email
2009-01-29 09:20:03

you need to get the minus number to match the objects speed. if the code says ._x -=5 and your character’s speed is set at 10, he slides through at a speed of 5.

 
 
Comment by awesty
2006-09-23 12:49:43

whoops, i just realised i mucked up a bit in the tutorial.
on the right wall put this code:
onClipEvent(enterFrame){
if(this.hitTest(_root.man)){
_root.man._x -= 5;
}
}

and on the left one put this:
onClipEvent(enterFrame){
if(this.hitTest(_root.man)){
_root.man._x = 5;
}
}

 
Comment by teesha
2006-09-28 00:49:29

Hi there , this is regarding the tutorial pencil . i tried it the drawing actually moved but the thing is i couldnt get the pencil to draw i draw the pencil is still” PLEASE HELP

 
Comment by awesty
2006-09-28 10:34:41

Sorry but I don’t know what you mean by pencil. :?

 
Comment by troy
2006-10-03 23:35:23

i did the tutorial, but my guy does not stop at the walls and just goes right through, im not sure what i did wrong though

 
Comment by haavard
2006-10-04 22:55:38

hi, thanks for a great tutorial the result was great! i fixed the actionscript there was a little mistake…

 
Comment by awesty
2006-10-06 17:12:31

@troy: Sorry but I have made a mistake in the tutorial. I am currently away and do not have flash on the computer I am on. Please read the comments above because it says how to fix it.
When I get back I will fix the tutorial.

Thanks. ;)

 
Comment by Jay
2006-10-16 00:25:58

Thanks!! It worked great!!!

 
Comment by DrP
2006-10-21 06:12:19

Nicely explained tutorial but I’m having the same problem.
My square goes through the wall if you keep the arrow pressed. If you release the arrow while the square is behind the wall, though, it works fine!

 
Comment by awesty
2006-10-21 11:20:57

Try doing this:

on the right wall put this code:
onClipEvent(enterFrame){
if(this.hitTest(_root.man)){
_root.man._x -= 5;
}
}

and on the left one put this:
onClipEvent(enterFrame){
if(this.hitTest(_root.man)){
_root.man._x = 5;
}
}

 
Comment by Norm
2006-10-27 10:29:22

Hey.. was working fine earlier but now as soon as I put the code for the right wall in, when I load the application the wall starts sliding to the left! Help! :)

 
Comment by awesty
2006-10-27 11:47:48

Try doing this:

on the right wall put this code:
onClipEvent(enterFrame){
if(this.hitTest(_root.man)){
_root.man._x -= 5;
}
}

and on the left one put this:
onClipEvent(enterFrame){
if(this.hitTest(_root.man)){
_root.man._x += 5;
}
}

 
Comment by norm
2006-10-28 00:51:05

Still no :( That’s what I already had. It seems that if I type any errors in the code, the wall stays still but nothing happens when the “man” collides with it. However, when I do everything correctly, the right wall starts moving to the left. Interestingly, if I put:

onClipEvent(enterFrame){
if(this.hitTest(_root.man)){
_root.man._x -= 25;
}
}

as the code, the right wall moves faster to the left, as if the _root.man. is referring to the wall itself?

 
Comment by awesty
2006-10-28 10:22:20

Make sure you have the instance name man on the right MovieClip.

If you want you can send the .fla to admin[@]awestyproductions[.]com. (Without the ‘[]’ ;) )

 
Comment by Andrew
2006-10-29 02:44:46

cool tutorial but if you update it could you put a script for if you move over something it goes to the next frame

 
Comment by awesty
2006-10-29 10:06:21

Just use this code:

onClipEvent(enterFrame){
if(this.hitTest(_root.NAME)){
_root.gotoAndPlay(FRAME);
}
}

Just replace NAME with the instance name of the movieclip and FRAME with the frame you want it to go to.

 
Comment by timmy
2006-11-03 15:20:57

when my man wnet near to the left wall it just got pushed out the walls i don’t know what i did wrong. Thanks

 
Comment by awesty
2006-11-03 17:55:47

Make sure you have you have the right code on the right wall.

 
Comment by timmy
2006-11-04 14:00:38

actually i am confused
can you show me the
Top wall code
bottom wall code
left wall code
and right wall code
Thanks alot!

 
Comment by awesty
2006-11-04 14:31:57

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

Left:
onClipEvent(enterFrame){
if(this.hitTest(_root.man)){
_root.man._x = 5;
}
}

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

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

 
Comment by timmy
2006-11-04 23:07:20

Thanks man!

 
Comment by timmy
2006-11-04 23:12:27

it still doesn’t work… may i send it to you?

 
Comment by timmy
2006-11-04 23:16:25

err i got another question can flash make similes?

 
Comment by awesty
2006-11-05 10:08:34

Yea, send it to me if you want.

Do you mean smilies? Because I have no idea what similes are.

 
Comment by timmy
2006-11-06 14:33:25

I sended the file to you, anyways similes is things like when you chat on msn some animation that can show your feelings…

 
Comment by awesty
2006-11-06 15:35:44

I though they were smilies or emoticons. :?

 
Comment by timmy
2006-11-11 17:42:15

yea i think so
anyways my older verson cant read flash 7 what can i do?

 
Comment by awesty
2006-11-12 10:00:04

Umm, what version of flash were you using when you sent it to me?

I only have Flash 8 so I can only save it as a Flash 8 or Flash 7 (MX 2004) file.

It wouldn’t work if you are using any previous version any way because it is a different version of actionscript.

 
Comment by timothy
2006-11-13 14:28:15

my flash verson is 5….

 
Comment by fjfjfj
2006-11-13 14:29:00

jjdd

 
Comment by awesty
2006-11-13 16:03:39

@timmy: Then this won’t work. Flash 5 uses ActionScript 1.0, Flash MX 2004 and above use 2.0 and the new Flash 9 is going to have ActionScript 3.0

http://www.awestyproductions.c.....cript-30s/

 
Comment by Flash Back Productions
2006-11-13 23:45:05

Thanks! so Much! now I can Make games

 
Comment by Webber
2006-11-15 11:52:36

hi first i wana say thanks most work fine for me (im a little slow ;) ) anyways, if i wanted to make a maze would i have to make center test hit or would it just be bottom etc from were its closest to?

ps: my business class is doing a project with flash so this is suuuuuper inportant it wouldnt be cheating just lots of help! :)

 
Comment by Webber
2006-11-15 13:12:06

PS: Westy you havent been noticing but uve been forgetting in the tutorials (or here in comments) the and - parts before the = 5;

so heres all the correct ones

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

Left:
onClipEvent(enterFrame){
if(this.hitTest(_root.man)){
_root.man._x = 5;
}
}

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

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

 
Comment by awesty
2006-11-15 15:22:33

I haven’t been forgetting them, for some reason they get taken out like yours. :\

I will try to do an advanced hitTest tutorial that will explain how to make a maze type thing.

 
Comment by andy
2006-11-15 20:52:14

it dosen’t work. he goes right through the wall like water

 
Comment by John
2006-11-16 04:24:42

Its awesome! I’ve been looking for this for awhile for my Rat ‘N’ Cheese Game (COPY RIGHT O_O). And for those of you who have errors, be sure to follow every step and dont delete any of the code. Make sure you have the -’s and ’s along with y’s and x’s. Also, I have a couple questions that I need to ask, could you E-mail me at kbb101@mail.com ? I may not see your reply here since I don’t come here often, and I’m mostly off the internet.

 
Comment by MadFools: Bert
2006-11-16 08:13:12

Dude, how would you use HitTest to make it so that when one thing collides with another, the WHOLE movie goes to another frame. I tried to do it with the following actionscript

onClipEvent (enterFrame) {
if (this.hitTest(_root.man)) {
gotoAndStop(2);
}
}

but it doesn’t work. e-mail me at MadFools.Bert@gmail.com

 
Comment by Webber
2006-11-17 06:23:28

actually can u post that script here i wana no to! :p

 
Comment by awesty
2006-11-17 09:37:34

Just change gotoAndStop(2); to _root.gotoAndStop(2);.

 
Comment by Hats
2006-11-19 06:55:15

Hey, this has been a great help. I know its a bit off the plot but could you tell me how to make an MC that slows down or speeds up the little guy?

Cheers

 
Comment by awesty
2006-11-19 09:20:10

I will do a tutorial today or tomorrow ;)

 
Comment by 0\/\/e|\|
2006-11-19 13:05:54

Is there a way to make an object or wall impassible on all sides?

 
Comment by Webber
2006-11-20 09:47:12

yeah just make the layer make it mc then use the black cursor to select each side, put the action script of the apropiate side and it should work (i havent tested)

 
Comment by awesty
2006-11-20 17:37:20

That would work, but there is a easier way. I will write a tutorial for the other way but I have heaps of tutorials I want to write that I don’t have time for.

 
Comment by webber
2006-11-21 01:26:16

sweet, why dont you just add it to your previous hit test tutorial?

 
Comment by webber
2006-11-21 01:28:04

also, i noticed you can go thru the wall if you have enough speed, im making a gravity type game, so how do i make it so its just simply “impossible” for the ball to go thru it at ANY speed?

 
Comment by awesty
2006-11-21 15:14:23

Because if people have already done this tutorial they aren’t likely to check back, but if they see there is a new one they might.

With the walls, your walls need to be thick. If you wall is only 2 pixels thick and your MC is traveling at 10 pixels, it is going to go straight past it without even touching it. So try to make your walls thicker than the speed the MC is traveling.

 
Comment by unknown
2006-11-26 00:38:37

nice one! i made a maze game with that one! thank you vm!

 
Comment by sam
2006-11-29 08:07:37

you typed “put this code in on top” twice :)

 
Comment by Teatles
2006-12-06 00:54:20

i put the code in for making the movie go to a different frame when two objects touch, but the movie just plays and repeats from the start, and flashes back and forth, so i cant move my character, because its just repeating these two frames instead of staying on one until the objects touch. how can i get that to happen?

 
Comment by teeno
2006-12-06 22:47:15

hey thnx a bunch agen i looked at ur movement tutorial and they are so easy to follow i have now made a maze game thnx it was hard work and tokk a long time im loking now to add little monster trap things which take down my health . thnx

 
Comment by Tom
2006-12-07 02:56:02

Hey, I’m having trouble with the hit test, I want to make it so my character that i move can’t go through a wall from either side, i tried to put in the coding for the X and -X, but it seems to slide from the right and work from left, please help xD.

 
Comment by awesty
2006-12-07 15:19:33

@Sam: Yea… lol

@Teatles: You need to put stop(); on both frames.

@Tom: Please read the previous posts.

 
Comment by Tom
2006-12-09 02:37:27

Hey, i tried to make a door where if it roots with my man it goes to the next frame, i used this coding;

onClipEvent(enterFrame){
if(this.hitTest(_root.man)){
_root.gotoAndStop(2);
}
}

But it just goes and plays at Scene 2, when it’s supposed to play Scene 4 frame 2.
and i’ve already tried .gotoAndStop(”Scene 4″, 2)
But it’s not working, any help would be great thanks.

 
Comment by John
2006-12-09 04:03:31

Hey good tuto, but i have a problem.
Whent the movie is tested, the man just walks through the left and top wall and gets stuck inside it. This is annoying me alot. Please help !!

 
Comment by awesty
2006-12-09 09:44:17

@Tom: Try changing _root.gotoAndStop(”Scene 4″, 2); to gotoAndStop(”Scene 4″, 2);.

@John: Change the top wall to this:

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

And the left to this:

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

 
Comment by John
2006-12-10 06:16:49

Ermmm ive tried the new code and ti still does not work it still is just walking through. I think it might be something to do with the fact that I have Flash MX 2002. Is there anything I can do ?

 
Comment by Tom
2006-12-10 07:39:34

John i’m having the same same problem and i have Flash MX, But i’m sure there’s a way of doing it :S

 
Comment by RDB2006
2006-12-10 10:43:51

im havin the same problem with the left wall, my char keeps going through it and gets stuck. My top, right, and bottom wall are fine tho. Any help? ty

 
Comment by awesty
2006-12-10 11:02:06

@John: If you have any version of flash previous to Flash MX 2004 and any version more recent then Flash 8 (which you shouldn’t since there isn’t) then it won’t work.

@Tom: Again, you need Flash MX 2004 or Flash 8, they have a different version of ActionScript.

@RDB2006: What version of flash are you using?

 
Comment by RDB2006
2006-12-10 21:40:07

Flash MX 2004

 
Comment by RDB2006
2006-12-10 21:41:28

w8 a min.. i think its cuz u have the wrong code for the left wall (You have the right walls code for the right wall, bottom for bottom, top for top, and top for left. it should be the left code for the left wall)

 
Comment by RDB2006
2006-12-10 21:44:42

i think :S

 
Comment by ya
2006-12-11 07:54:41

thanks! It was awesome!!!!

 
Comment by ya
2006-12-11 07:55:16

thanks! It is awesome!!!

 
Comment by awesty
2006-12-11 15:39:53

@RDB2006: Yes, you are correct.

 
Comment by sjfb.gf
2006-12-12 06:08:52

that was good but it din’t tell us how to do heath

 
Comment by bob
2006-12-12 10:35:38

i don’t see anything!

 
Comment by awesty
2006-12-12 15:51:54

@sjfb.gf: Thats a different tutorial:

http://www.awestyproductions.com/tutorials/

@Bob: Make sure you have the latest flash player.

 
Comment by Bryce K :P
2006-12-20 12:04:21

thanx awesty nice work couldn’t have done it better myself (even if i knew how :P lol)

 
Comment by Tai
2006-12-21 07:54:42

my man just goes passed the wall after its done sliding slightly to the left or right

 
Comment by awesty
2006-12-21 11:09:05

Make sure you have the right code on the right wall.

 
2006-12-21 20:03:06

[…] This tutorial will be a whole lot easier if you have already taken my Moving MovieClips with the arrow keys, Making walls with hitTests and Making a health system tutorials since alot of the script used in those will be used in this tutorial so I won’t go into as much detail with them as I might with the rest of the script. […]

 
Comment by Spleen
2006-12-22 02:49:15

When i tried this, it had a gap between him and the wall, is there anyway to get rid of this gap?

 
Comment by Tai
2006-12-22 07:32:43

i did get the right code for the right walls and i aready took ur other tutorials

 
Comment by awesty
2006-12-22 11:01:22

@Spleen: Yes. Try my other tutorial on hitTests. It is much better.

http://www.awestyproductions.c.....ts-part-2/

@Tai: Make sure the character isn\’t moving faster than the walls are repelling him.

 
Comment by RDB2006
2006-12-23 01:10:50

@Tai if your wall is on the right hand side try putting this code on it:

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

if its on the left hand side try putting this on it:

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

 
Comment by tai
2006-12-23 07:12:50

my man still goes through the wall this is going to be the last thing i need to do for my first stage of my fighting game

 
Comment by awesty
2006-12-23 12:28:48

Just email the .fla to here:

awestyproductions@gmail.com

 
Comment by kinto
2007-01-01 03:08:38

YOUR TUTORIAL IS AWESOME AND REALLY EASY TO FOLLOW!

 
Comment by Djo
2007-01-06 01:00:40

Yo awesty..
nice tut.. im not a programmer at all
im more of a designer animator

i was wonderin of u could help me out with
some AS 2.0 scripts for my first game..

http://www.djo-e.com/TEST/game.html
click to view a preview
if your intrested
please mail to infodjo-e.com

 
Comment by awesty
2007-01-06 11:58:47

I sent you an email.

 
Comment by kev
2007-01-11 01:53:50

nice tutorial man but u should make better drawings but still the tutorial is sick and it finally worked not like the health system 1.

 
Comment by bananarchy
2007-02-02 22:03:32

thnx! from this basic tutorial i already have a gate that can open with a button O.o

 
Comment by Kurt
2007-02-07 11:43:50

Sorry that this is really off topic but i want people to comment the games i create for my website, How did you get that blog or what html did you use i hope you can answer.

Kurt.

 
Comment by Phil
2007-02-17 01:50:21

Kurt how much izzit for a website?
also Awesty 2 things how is yur name pronounced &
I wanna make the best game ever. if i go 2 times
a day how long wood it take?
a month or 2?
every one else
the = 5
should be
plus= 5
plus is plus symbol

 
Comment by Phil
2007-02-17 01:52:34

yur welcome Awesty & everyone else

 
Comment by Phil
2007-02-17 01:54:13

noone awnsers after me!!!

 
Comment by awesty
2007-02-17 12:49:23

@Kurt: http://www.wordpress.org

@Phil: Be patient :P

My name is pronounced:

A - westy.

The A is separate. Btw awesty isnt my real name, it is kind of a combination of my first and last name.

And it depends on how big the game you are making is.

 
Comment by Kaz
2007-02-21 03:42:33

I was just wondering, my wall makes the object that i’m moving jump off it, it doesn’t hit it and stop there, also if I have speed up the object that I’m moving it goes through the wall.

 
Comment by awesty
2007-02-21 15:31:19

Your walls need to be thicker than the speed you are moving. If you are moving at 10 pixels a frame, and the wall is only 2 pixels the MC will go straight through the wall.

 
Comment by Kaz
2007-02-22 04:24:27

Ok thanks =D

 
Comment by Anon
2007-03-22 07:22:08

How do I ensure that it is exactly 25 pixels, is there a box I can fill in or something?

 
Comment by awesty
2007-04-05 13:31:50

@Anon: There is a box in the properties panel.

 
Comment by sam
2007-04-06 13:34:46

hey…cool tute…im making a car racing game and i have two cars…(p1 and p2) i was wondering how to make it so the hit test on the walls can be for both cars…for example this would be for 1 car…

onClipEvent (enterFrame) {
if (this.hitTest(_root.car1)) {
_root.car1._x -= 5;
}
}

so how do i make it for car1 and car2?

i also need some help with codes for the finish line…so it can detect who wins and only shows the winner screen after say 3 laps…hope u can help

sam.

 
Comment by awesty
2007-04-06 21:18:48

@sam: You could just have two separate if statements for each car. So like if(this.hitTest(_root.car1)){ and if(this.hitTest(_root.car2)){.

For the finish line part, you could do something like:

if(this.hitTest(_root.car1)){
_root.gotoAndStop(WinFrame1);
}else if(this.hitTest(_root.car2)){
_root.gotoAndStop(WinFrame2);
}

But obviously you have to change WinFrame1 and WinFrame2 to actual frames.

 
Comment by Giuliano
2007-04-15 12:40:38

it is not working. all that happens is it slows down a little than it goes through. what should i do.

 
Comment by awesty
2007-04-15 15:12:45

Make sure the speed it is being repelled by the wall is equal to or less than the speed the MC is moving.

 
Comment by Soon2BeAmazing Subscribed to comments via email
2007-05-27 11:31:13

Great Tut! As said above, now no more copy/paste, jsut understand, UNDERstand, UNDERSTAND!
set(Awesty = Amazing)

 
Comment by Ricky Shroder Subscribed to comments via email
2007-06-06 13:31:20

Awesome tutorial.

The best part is all the spelling and grammar mistakes.

You is be good of Flash, is like to maek rectanlges be good.

 
Comment by destructin Subscribed to comments via email
2007-07-28 05:06:50

it doesn’t work, it just pushes my man.

Comment by destructin Subscribed to comments via email
2007-07-29 04:50:22

nvm i got it to work

 
 
Comment by bryce Subscribed to comments via email
2007-07-31 14:32:31

hello i put the code in correctly but it doesnt work. what happens is — if the man doest go the out if the stage fully when it hits the walls it comes back in automaticly but if it does go out of the stage completly it doesnt come back.

PLEASE HELLLLP ME :)

 
Comment by Robin Subscribed to comments via email
2007-10-06 05:06:35

Didn’t read all the comments but for those of you having problems with the hero sliding through the wall… I gave it a thought and at the code:
and on the left one put this:
onClipEvent(enterFrame){
if(this.hitTest(_root.man)){
_root.man._x += 5;

 
Comment by Boston Subscribed to comments via email
2007-12-03 12:59:20

Hey Awesty (if that’s really your name…)

I’ve made walls for my game, but I need the char to not to enter from any side.
- I’m guessing that what I have to do is subtract the char’s x/y coordinates by the wall’s and if it’s pos/neg, a boolean will tell the script to ‘move’ the char in the appropriate direction. Is this right? How do I actually do this?

- Another problem is that using the basic ‘one-sided’ walls you explained in this tut, it is successful in stopping my char from walking into the wall, but not the stage(which follows the character around) I know the code for the stage to move but not how to get the wall to stop it. :(

Here’s what’s on the wall:

onClipEvent(enterFrame){
if(this.hitTest(_root.man1)){
_root.man1._y -= 4;
_root.Stage._y = 4;
}
}
This doesn’t work to stop the ‘camera’.

If you don’t get what I’m saying, just ask for me to send an fla.

Thanks for the help.

 
Comment by Boston Subscribed to comments via email
2007-12-03 13:04:19

whoops, there’s a mistake…

_root.Stage._y -= 4;

should be:

_root.Stage._y = 4;

(The code still doesn’t work correctly ofcourse)

 
Comment by Boston Subscribed to comments via email
2007-12-03 13:07:11

‘+’ doesn’t work? :/

 
Comment by Horhey Subscribed to comments via email
2008-01-11 08:40:44

I understand exactly how to do this. But what if I wanted, well I do, to do this with a cursor. I tried using the same AS but it wont work. What can I use?

Comment by awesty
2008-01-11 13:20:10

I don’t get what you mean.

You want the cursor to collide with the walls?

Comment by Boston Subscribed to comments via email
2008-01-11 16:59:20

No, I have a character which moves using the arrow keys, I just don’t know a simple way to stop the char walking through the walls from all sides.

Comment by awesty
2008-01-12 11:12:40

Sorry, but you have to use actionscript.

There is a program which allows you to make games without any code. It’s called GameMaker. If you google the name its website should come up.

Comment by Boston Subscribed to comments via email
2008-01-12 15:09:03

hahaha :)

no no I understand Actionscript. If you look at my rpevious comments I have already posted code up there… I’m just asking for the code to stop the char if he hits any side of an object (he cant enter the object from any angle), ex:
char moves diagonally and hits the wall, he can never overlap with the object. Do you know how to code this?

(Comments wont nest below this level)
Comment by Boston Subscribed to comments via email
2008-01-12 15:10:47

btw, that guy up there who talks about stopping his cursor is NOT me, I’m Boston only

sorry for the confusion, but I’d also like to know what code you’d need to do what he’s asking for too… ;)

 
Comment by awesty
2008-01-12 15:15:53

Oh, okay.

I have written a tutorial for that. You can find it here:
http://www.awestyproductions.c.....ts-part-2/

 
Comment by Boston Subscribed to comments via email
2008-01-12 15:18:18

fast reply! thanks

 
 
 
 
 
 
Comment by N2KC Subscribed to comments via email
2008-01-27 04:39:22

Ooooh. Duh. Why didn’t I think of that? I thought it would be more complicated. Is there a way you can have the wall as a movie clip, place it in the middle, and have it block you on all sides?

 
Comment by Sean Subscribed to comments via email
2008-02-15 04:04:21

THE BEST TOTURIAL EVER!

 
2008-03-09 04:20:30

jugar poker en linea…

No es importante dados poquer juegos poker shareware…

 
Comment by MJM Subscribed to comments via email
2008-04-16 02:21:55

i was doing another one of your tutorials and it put a fake gravity on my guy and the bottom barrier dosn’t keep him in the frame. how do i fix it?
:/

 
Comment by qball Subscribed to comments via email
2008-05-05 04:37:32

Hi, would you know how to get a ball to bounce off a character that is moving around the screen? I have it bouncing off the walls, but cant get it to bounce off my character.

Thanks

 
Comment by rudydbooty
2008-07-13 09:58:07

wow this is what i was looking for but if you go on the right he goes through the wall

thanks everyone for making adjustments

 
Comment by julian Subscribed to comments via email
2008-08-17 13:35:19

HI THERE
im having a problem
im trying to make a maze game but the man
keeps going through the other
sides
and i can’t stop the man from going through each sides of the wall.

can you help me?

-julian

 
Comment by Marre2795 Subscribed to comments via email
2008-09-22 04:43:38

This helped me a lot, but when i comes near a wall cant get away from it

 
Comment by awestys fan
2008-10-11 12:46:10

WHAT DO I DO FOR BUTTON TO GO TO NEXT KEY FRAME AND HOW NAME!

error:

**Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 1: Syntax error.
onHitGoto”2″

Total ActionScript Errors: 1 Reported Errors: 1

help!

 
Comment by julian Subscribed to comments via email
2009-03-01 07:44:43

try this:

on(release){
gotoAndStop(2);
}

hope this helps

 
Comment by minty Subscribed to comments via email
2009-03-09 03:34:46

thanks, this has realy helped me. A realy usefull thing, I;d never sigured out how to do this withouth help :)

 
Comment by julian Subscribed to comments via email
2009-03-10 16:36:30

happy to help

:)

 
Comment by jsh Subscribed to comments via email
2009-04-16 10:54:09

Hey that code doesn’t work for me… I still walk through it like it isn’t there. What do you think could have gone wrong? Anyone, PLEASE HELP!!!!

 
Comment by jsh Subscribed to comments via email
2009-04-16 10:56:33

Oh, yeah… I converted it into a symbol and applied actionscript to it but it still doesn’t work.

 
Comment by warren Subscribed to comments via email
2009-04-24 21:51:06

hi i have put the code in the wall and it works fine. by changing the value you can make your character iether stop, slow or bounce off. but what if ound is you can not make a 2nd wall that stops it from moving left. for example only one wall can stop each direction up, down, right, left. if i make a second wall to stop it moving lelft it will go strait through that one. anyone no how to fix this

 
Comment by Luke Subscribed to comments via email
2009-06-06 08:44:05

Hi,
I just downloaded flash pro 8 and is quite good but the actionscript box always says that i cant write in it even when somethings an symbol! Its really annoying i wonder if anyone can help?

 
Comment by Hemsby5472 Subscribed to comments via email
2009-07-22 07:11:20

Hey thanks, this made my creation a breeze!

 
Comment by samir uddin Subscribed to comments via email
2009-09-08 04:28:04

cheers, man.
for so damn long iv’e been looking for a tutorial that does this and i cant believe no one else has actually created a tutorial for this. i search for this but all i find is a collision detection just saying “colision” and no wall code.(no simple one anyway). thanks dude u rock!

 
Name (required)
E-mail (required - never shown publicly)
URI
Subscribe to comments via email
Your Comment (smaller size | larger size)
You may use <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong> in your comment.