
About Line2D Object:Behaviour
HariBabu Suraneni
While I am working in www.onemg.in as a Flash Developer, I have really entered into Flash Script writing even though I started my career with AS2 in 2007. From that humble begening, now I have grown up to a successfull AS3 programmer. In my process of learning, actionscript org has a major role as I Learnt so much from the published tutorials and forums.
Now, I think I have learnt some new techniques that are rarely finding their place in these articles, I want to share my knowledge through some of the educative tutorials.
View all articles by HariBabu Suraneni
About Line2D Object:Behaviour
As I promised you earlier, I am showing a demo how really Line2D behaves and exhibits it's features. I am not going to explain all the known things to you again. just see it and understand. what you need to do is just clicking on start button, that's all. If you want to change the speed, change it before clicking start button. After FINISHED button appears, just click reset button.
When you click the start button,You will observe two things. The black line is moving to sides without changing any of its angle,length etc.I used moveTo with one unit speed incriment in that suggestive enterframe function.
my_Line1.moveTo(my_Line1.p0.x+1,my_Line1.p0.y);
And for the green line I used the other function moveBy.:
my_Line2.moveBy(5);
And I have created a Line at the bottom of the stage and made it to bounce back when it touches that Line.I am not giving the full code as it is similar to the above static example. Only difference is Projection is moving here in enterframe event. The moveBy is taking the speed as single argument and It is moving in the same angular direction in each cycle of the movement. I am reminding you that what you see here is not a MovieClip Animation. I gave a render function to this Invisible mathematical object Line2D to make this demo a lesser complicated. In Real applications, We could remove it and It willl work like Point object. By reading it's values, We can position our display Object at the required Coordinates. I have added a clone method to the Line2D object, which is useful for reset functionality. This is very useful when we want to render earlier unchanged movement pattern after manipulating the basic line for a no of times. You need to simply clone the original object and keep it there. After a series of processing statements for that particular Line2D, You can then assign that clone object's values.
This is all Line2D can do for us. As an Object wise, It's functionality is very simple. All the functionality I showed above is enough. But, If you see it as a prototype of a CollisionDetectionEngine, we can do wonders with it. Currently, I have followed all the new animation techniques which are showcasing a beautiful potency of 2d and 3D packages. Their basic display and Simple Animation features are nice. But, when we checked for their Collision detection feasibility, they are failing to create an Event based architecture around them. I have followed hitTarget logic, Verlet Integration and others, very carefully. I am very much impressed by their accuracy. But, as you saw those three messages in the final example, as three Event Types, COLLISION_START, COLISION_PROGRESS and COLLISION_OVER states of CollisionEvent, you would agree with me that this Line2D object has achieved 90% of the CollisionEvent. It can do more If we can convert into Line3D by giving Point3Ds as arguments and can insert the z in its dotproduct,crossProduct and perProduct functions, and more importantly we could get the 3 Features Isect,bounce and Touch with 3D orientations, We can redefine the Flash3D world. Currently Flash 3d cannot show intersecting planes, Right? That can be achieved If we Thought of them as individual vertices and Line3Ds. As it seems to me that one Axis3D will run from the bottom most z to top most z and all the objects were described with their touchpoints on the Axis3D without bothering about parent-Child relations.if we change Axis orientation, we can transform them with their RelativeIntegralValues (RTV). Most of the redundant matrix calculations would give way to Simple and direct calculations. Currently I am fully Ignorant about that Line3D implimentation. If anybody enlighten me on that subject of Math3D, I would Update this Line2D Object in its new Avatar Line3D. Until then, Line2D will serve as a backbone for CollisionDetection in 2D.
I NEVER DO PURPOSE LESS THINGS.
Spread The Word
3 Responses to "I have created a line2D object for 2D collision detection" 
|
said this on 07 Feb 2011 4:53:13 PM CDT
Hi Haribabu,
I am very much impressed I am looking for maths [email protected] Ur name sounds like I |
|
said this on 18 Jun 2011 9:57:54 PM CDT
Home run! Great slugging
|


Author/Admin)