I am trying to make a side scrolling shooting game (my first venture into any ActionScript programming) and I am having quite a bit of trouble. First, I am trying to get inspiration and help from online tutorials, but what I can find are largely for AS2, or don’t do quite what I’m looking for and lead me to a dead end. I have been able to work out nearly everything with some stubbornness but I’m afraid I’ve finally hit my wall–the shooting part.
To get to this issue itself, I am trying to place an instance of a bullet (movieclip created by AS) on the character’s gun, to which I’ve attached an empty movieclip called “bulletHolder”. Ultimately, I’d like to take the point of the gun and the point of the cursor on the screen, find the slope, and make the bullet follow that path. THe problem is, so far, I can’t attach the bullet clip to the gun/gunholder. I don’t see anything wrong with my code, and I get no errors, but clicking to fire (which should attach the clip) simply seems to do nothing. If anyone could point out what I’m doing wrong I would really appreciate it!
var gun:Gun = new Gun();
gun.x = p1_mc.x;
gun.y = p1_mc.y + 10;
//p1_mc is the character. Gun is kind of obvious.
var bulletHolder:MovieClip = new MovieClip();
//i’m not sure if I need the bulletHolder, but I tutorial i was following suggested it. Is there a good reason for making this empty movie clip, or could I do without it?
var bullet:MovieClip = new MovieClip();
bullet.graphics.drawCircle(0, 0, 2);
function createBullet(startx:Number, starty:Number)
bullet.x = startx;
bullet.y = starty;