|
-
CS3 AS2.0 - Collision problem
Hi Flashkit community,
I have a small problem I would like your help on today. I know I should be close to the answer, but spending hours trying to figure it out, my mind just crashed... so I'm asking for any help at all.
Code:
this.onEnterFrame = function(){
moveUpArrow();
moveDownArrow();
moveLeftArrow();
moveRightArrow();
if(_root.rootClip.hitBox_mc.hitTest(_root.upArrowMc)) {
_root.rootClip.score ++;
}
}
var arrowSpeed = 2.5;
var arrowReady = true;
var arrowDelay = 130;
var arrowArray = [];
var arrowCount = 0;
function createUpArrow(){
var upArrowMc = _root.rootClip.attachMovie("Up", "Up" + arrowCount, 1000 + arrowCount);
arrowCount ++;
upArrowMc._x = 500;
upArrowMc._y = 768
arrowArray.push(upArrowMc);
}
function moveUpArrow(){
if(arrowReady && Key.isDown(Key.UP)){
arrowReady = false;
currentTime = getTimer();
createUpArrow();
_root.rootClip.score += random(100) +1;
} else{
if(currentTime + arrowDelay <= getTimer()){
arrowReady = true;
}
}
for (var i = 0; i<arrowArray.length; i++){
arrowArray[i]._y -= arrowSpeed;
}
}
This is what I got right now, I left out the code for Down, Left and Right functions, since they are pretty much the same.
THE PROBLEM I have is the collision area... for some reason, the collision doesn't detect when there is an array involved with an attached MC. I know there has to be a way to detect this collision, (ie. games that have shooting bullets, damaging enemies, etc)
So if anyone can modify my code, or even just point me into the right direction, I would be very grateful.
Thanks in advance!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|