Thanks for to look in this thread.
Can any one explain me properly and priciously about hitTest() of MovieClip.
I am making a game and this hit test problem has been much sticky for me.
See my problem is :
(1) one object is droping form the top of the stage towards down side (consider as water level) to sink.
- with random speed of folling objects.
- so I am initialising a random no to random objets (e.g. randomRange(1,7))
- now, what happens that I have a one level consider (e.g. waterLevel) at some size of (_x = 400 and _y = 430)
and my stage size is ( width=400 and height = 460) - now condition is that every object folling form top should be die if his parachoots is not opened before it touches to waterLevel.
- I increament the _y property of every fallingObject by this randomly generated Num. cotinuously ( onEnterFrame event )
- so problem is, when I increamet _y by randomly generated Num for some falling objects hit test does not occur and for some it occurs.
- for my waterLevel I have taken a MovieClip of water color and its shape is ( e.g.ractangular with curve shape like water is shaking/moving ) and in that movie clip I hava taken a dummy movie clip (e.g. emptyWaterMC of ractangular shape) and keep it as _hitArea of its parent MovieClip
!!! ???can any one explain me what should I do to get hitTest, always, by incrementing with randomly generated Num. ???
snippet some thing like*
var fallingObj_MC : MovieClip;
fallingObj_MC = target.attachMovie(“abc”,“xyz”,target.getNextHighestDepth ());
// randomRange(lowNum,hiNum) generates random numers of given range
var randNum : Number = randomRang(1,7);
fallingObj.onEnterFrame = function()
{
this._y += randNum;
}
// now for water Level
var waterLevel : MovieClip;
var emptyWater : MovieClip;
waterLevel.hitArea = emptyWater;
watchOnWaterLevel.onEnterFrame = fucniton()
{
//I am checking hit test here
if(this.hitTest(fallingObj))
{
trace(“hit done”);
callObjectSink();
}
}
****** snippet end*************
Thanking you in advance