I’m trying to create a basic app where you shoot MCs moving at random. That part works but I’m not sure how I can call an Array at random instead of keeping to the basic shape I’m using now, would be fun with a bit of difference…
Any idea how I could achieve that usig the below code?
var i;
// get sound
var gunfire = new Sound();
gunfire.attachSound("gunfire");
_root.hit1.onPress = function() {
gunfire.start();
i++;
_root.bull.duplicateMovieClip("bulletNew", i);
if (i == 10) {
i = 0;
}
// hit test on target
if (_root.target_mc.hitTest(_root._xmouse, _root._ymouse, false)) {
_root.gun.gotoAndPlay(2);
_root.target_mc._x = 0;
_root.target_mc._y = random(300);
_root["bulletNew"+x].removeMovieClip();
}
};
// initialise stuff
_root.onLoad = function() {
// hide the mouse
Mouse.hide();
};
//loop
_root.onEnterFrame = function() {
//put cross hairs to mouse coords
_root.gun._x = _root._xmouse;
_root.gun._y = _root._ymouse;
// target move
_root.target_mc._x += 10;
if (_root.target_mc._x<0 || _root.target_mc._x>Stage.width) {
_root.target_mc._x = 0;
_root.target_mc._y = random(300);
}
};
Appreciate any kind suggestions!!!
Yossi