Jonny_5 Posted November 27, 2009 Posted November 27, 2009 Basically i have my little car goin around but if it hits the sides it doesnt do anything i want it to move to another keyframe. If anyone flash experts know the codes then please help meee!! Thankz:P
localzuk Posted November 27, 2009 Posted November 27, 2009 I'm not particularly a flash expert, but collision detection is pretty much the same whatever language. You need some form of script to monitor the objects, and see when their boundaries cross/touch. This video may help: [ame=http://www.youtube.com/watch?v=iUbX9tFtqTg]YouTube- Flash AS3 Collision Detection[/ame] 1
stuj1 Posted November 29, 2009 Posted November 29, 2009 is it as2 or as3? When you move the car you want to get it's x and y position. Then use an if statement so that: if(car.x < 0) { // hit the left wall } else if(car.x > Stage.width) { // hit the right wall } if(car.y < 0) { // hit the ceiling } else if(car.y > Stage.height) { // hit the floor } You can adjust the values to take into account the car's width by using this instead: if(car.x-(car.width/2) < 0) Failing that use the hitTest method, placing movieclips around the outside. Check the Flash help for hitTest
StewartKnight Posted November 30, 2009 Posted November 30, 2009 you need the hittest i.e. if (car.hitTest(line1)) { gotoAndStop(2); } if (car.hitTest(end)) { gotoAndStop(4); } }; Instead of goto and stop, you could have nextFrame Send me your email address, and I'll email you some working code as a demonstration! 1
Jonny_5 Posted November 30, 2009 Author Posted November 30, 2009 my email adress is [email protected] thnx alot
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now