Actionscript [Collision of 2 Movie Clips]
:: Lessons :: Advance Lessons
Page 1 of 1
Actionscript [Collision of 2 Movie Clips]
There are 2 instances called MC_Target && MC, we will determine if the two movie clips collided
and display trace message "hit" when it does we will be using HitTest function.
Movieclip.HitTest(Targetx,Targety,true) returns true if Movieclip's x & y is the same as the targets x and y.
[frame]
and display trace message "hit" when it does we will be using HitTest function.
Movieclip.HitTest(Targetx,Targety,true) returns true if Movieclip's x & y is the same as the targets x and y.
[frame]
- Code:
// let MC follow wherever the mouse moves
MC.onMouseMove = function(){
MC._x = _root._xmouse;
MC._y = _root._ymouse;
}
Mouse.hide(); // hide mouse;
// mouse is clicked
MC.onMouseDown= function(){
//check collision
if(MC_Target.hitTest(MC)){
trace("hit");//displays this when MC hits MC_Target and button is clicked
}
}
Wingedge- Admin
-
Number of posts : 77
Age : 40
Name : Sir Francis
Year Level : Instructor
Location : UC
Registration date : 2008-06-10
Credits
GP: 9999
Similar topics
» Actionscript [Moving Movie Clips using Keyboard]
» Actionscript [Variable Declaration]
» Actionscript [Firing Projectiles]
» Actionscript [MC always faces the mouse]
» Actionscript [MC follows mouse and hiding mouse cursor]
» Actionscript [Variable Declaration]
» Actionscript [Firing Projectiles]
» Actionscript [MC always faces the mouse]
» Actionscript [MC follows mouse and hiding mouse cursor]
:: Lessons :: Advance Lessons
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum