Collision « Animation « Flash Tutorials

Home
Flash Tutorials
1.Actionscript Programming
2.Animals
3.Animation
4.Colors
5.Design
6.Effects
7.Game Cartoon
8.Humans
9.Models
10.Nature
11.Operations
12.Shapes
Photoshop Tutorials
Maya Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
Flash Tutorials » Animation » Collision 

package { import flash.display.MovieClip; import flash.display.Sprite; import flash.events.MouseEvent; import flash.utils.Timer; import flash.events.TimerEvent;

I'm making the flash file at the same time as I write this so there could be some errors in it. But I think I could.

First it calculates the offset for it. The code describes how it works, but not so fantastically. If you experiment with it a little and think a bit I think you could understand what happens with the code.

Discussed on this page:

collision detection, point on shape hits any point on other shape's border, localToGlobal, hittest, simulating physics (gravity, damping)

In this tutorial we will check for collisions between MC's (Movie Clips) that are created through actionscript. The way we will be doing it won't lag very much compared to a lot of the other ways you can do this and I will explain why later. I am using Adobe Flash CS3 but Macromedia Flash 8 and Flash MX 2004 will work as well. If you are using Flash CS3 make sure you select a AS 2.0 file.

[ a guide of all elements displayed in our FLA file ]

1. First open up a new Flash document. For this example I set my stage to 400x200. The first object we are going to create is our target movie clip. I made a box that was 150x150 and filled it with a medium gray. Once you make the box select it and press F8 to make it a symbol. Make sure that Movie Clip is set as the behavior type and name it target. Now that it is a symbol give it an instance name of target_mc.

Learn how to make a basic maze game with collision detection. Collision detection is useful in many different game type scenarios and is easier than you might think. The Collision Detection ensures that the Blue Ball (or Player) does not cross the red lines of the Maze.

w___ww.__j__a_va___2_s.___c___o_m | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.