luster
December 30, 2002, 11:38am
1
Hi,
I made,following one of the tutorials, a car that moves using keys like Up,Down,Left,Right.
Now i wonder how to do it that you draw a layer “wall” and if the car drives, it cannot pass it, it has to go around.(Like a maze)
I think this has maybe something to do with collision detection.
Please reply!!!
system
December 30, 2002, 12:47pm
2
on my game i just used hitTest() function… i guess you could’ve also limited that but getting the x and y coordinates and comparing them to the wall’s coordinates… for a maze, i dont think the latter method would work efficiently, i guess you’d have to use hitTest()
cheers
:A+:
system
December 30, 2002, 1:31pm
3
you will have to create a movie clip with an instance name like “wall ” and use a script similar to that:
if (wall.hitTest(getBounds(_root).xMax, _y, true)) {
speed = 0;
}
if (wall.hitTest(getBounds(_root).xMin, _y, true)) {
speed = 0;
}
if (wall.hitTest(_x, getBounds(_root).yMax, true)) {
speed = 0;
}
if (wall.hitTest(_x, getBounds(_root).yMin, true)) {
speed = 0;
}
=)
system
December 31, 2002, 5:39am
4
Interesting line of code guigo… With the getbounds…
Will that test every x pixel for the bounds of the car with that… or just the maxX pixel?
UGHH… Nevemrind… I’m stupid I’m editting this after previewing it again…
hits himself with a giant salami
system
December 31, 2002, 5:32pm
5
[SIZE=1]::I feel some code-explaining needed::[/SIZE]
system
January 1, 2003, 12:13am
6
Not to hard to explain.
Its saying if the wall got hi by anything moving trace the bounds witch is tghe lines out side the object and make it stop.
system
January 1, 2003, 4:37pm
7
I tried the code for a time ,but it doesn’t work.
When i move the car, the wall moves with it!
Thanks, but please help
system
January 1, 2003, 5:29pm
8
Luster do you have AIM.MSN If you do what is it.
Well i made a car game example a while ago and here is the link to the post.
http://www.kirupaforum.com/showthread.php?s=&threadid=11576&highlight=Car+example
system
January 2, 2003, 11:48am
9
my computer is on repair.
That piece of code must be placed on an enterframe handler, and, yes BullDog, it does exactly what you said.
I´m fixing some fla for you guys, jus give me a min or two:)