Please help me. I’m the beginner in actionscript
I’m try to make the Collision Detected with hitTest for long time but it doesn’t work. I have two objecct one is the Spaceship and rock. When those two hit each other. I want it to show text “Collision Detected”
This is my script
Frame1 script
var rockCount = 0;
var rockTimeGap = 1;
var nextRockTime = 0;
var startTime = getTimer();
stop();
MyTimer script
onClipEvent (enterFrame) {
timeElapsed = Math.round((getTimer()-_root.startTime)/1000);
if (timeElapsed>=_root.nextRockTime) {
_root.rockCount++;
//_global.RockNum = _root.rockCount;
newRock = _root.rock.duplicateMovieClip(‘rock’+_root.rockCount, 100+_root.rockCount);
//trace(‘rock’+_root.rockCount)
newScale = Math.random()*80+50;
newRock._xscale = newScale;
newRock._yscale = newScale;
//set the start edge of new rock
newRock._x = Math.random()*550;
newRock._y = Math.random()*10;
_root.nextRockTime += _root.rockTimeGap;
}
}
Script in Spaceship MC
onClipEvent (enterFrame) {
if (_root.Spaceship, hitTest(‘rock’+_root.rockCount)) {
trace(‘rock’+_root.rockCount)
_root.text = “Collision Detected”;
} else {
_root.text = “No Collision”;
}
}
The above is Flash MX actionscript