first, we really have no way of knowing what kinds of tools you're using, what language you're programming with, or several other parameters one needs to consider when building a game. but i'll assume your using Flash and AS3, both of which are the tools of the trade. yes, one can still program in AS2, but AS3 is the most current language version and if you haven't started learning yet - learn AS3 - even it will be updated sometime soon.
if you haven't considered/discovered this already, you will have to write some code in order to achieve you goals here. although you 'can' use some tools that are out there (like gamemaker) but you will not succeed even with that if you don't learn the syntax of their system.
ok, let's see if i can sum this up
so - first you need two mc or sprites, one robot, one bullet.
next - you'll need to have a 'trigger' to shoot, right - so you'll need to set up a keyboard or mouse event *listener*. listeners are an important part of making game UI (user interface) these are the triggers that tell us the user is doing something, and we must respond to that input.
let's assume the robot is placed on the stage, just standing there for now, doin nothin - we want to simply make him shoot. so we need our trigger/listener - so let's use the mouse for now (simpler), so we need to write some code, make a new layer above the robot's layer in the main timeline, title it 'actions', select the first keyframe and open the 'actions' panel (or use F9) - this is where you write code - we need to create a basic listener for a mouse event, that event then is 'handled' by a method we will define - here's the line:
addEventListener( MouseEvent.CLICK, shoot );
function shoot( e:MouseEvent ):void {
//our code to shoot will go here
}
the first line 'adds' the listener for a mouse event to the main timeline or 'stage' - the second thingy there is a 'method' - this will be triggered or 'handled' by the mouse event - you can see we've targeted this method in the listener (ie. shoot)
now we have a few things to do in the method in order to get the robot to fire the bullet - we need to make an instance of the bullet and that bullet has to either 'know' or be 'told to' travel in the direction it was fired. to create a bullet out of thin air, we need to 'instantiate' an instance of the Library Class - we do this by using a 'linkage id' - so let's do that: you've drawn a bullet, and converted it to a symbol, let's say MC (movieclip) (aside: easy people, keepin this basic) - so, in the properties panel of the MC (right click the symbol in the Library) give it a linkage id - say, "Bullet" (that's original...lol) now we can 'link' to the symbol by using the id in our code - so back to the code - in the method shoot(), we'll start off by building the bullet instance like so:
var b:MovieClip = new Bullet(); //"Bullet" is the linkage id
now we need to tell the bullet where to be, well, we want it to come from the robot, right, so we'll use the robots coordinates as our basis, then add a little to position it wherever the 'gun' will be - but that will be up to you since i don't know those things - for now i will use arbitrary increments, assuming the registration point of the robot is at center, and he's around 40, 40, let say, +20x and +0y (center y, right x) and we'll fire to the right - so let's add that to the code:
b.x = robot.x + 20;
b.y = robot.y;
now that we have 1) made the bullet, 2) told it where to be - now we have to add it to the DisplayList so we can see it:
addChild( b );
ok - doing good so far - now the next thing is making the bullet move. so on every frame (or any increment) we want to adjust the position of the bullet, in our case right now, to the right. how fast? well depends on what your doing, so let's just say about 20 pixles per frame - that's pretty fast. however we still need a mechanism to do that on every frame - couple of ways to go here (in fact there are several ways/methods to do this overall) - 1) could create a frame event on the instance, or 2) use a single frame event and iterate over any/many instance - the latter is more popular and more efficient by most standards. but i'm not going to go into the complications of iterating an array, that is more advanced - let's just give the bullet an event listener that will make it move and 'assign' it to the instance for now. so we need to target the instance with the listener, and create a method to process the motion, so back in our shoot() method we'd add:
b.addEventListener( Event.ENTER_FRAME, move );
and we'll create another method like this, that is the handler for the event:
function move( e:Event ):void {
e.currentTarget.x += 20;
}
you'll notice "e.currentTarget" - ? what the heck is that? well 'currentTarget' is a 'roperty' of the Event class that tells us what the event is in reference to - in other words, the bullet - but more specifically *that* particular bullet instance (there's more to it but marching on...)
but we also need to think about something else here - what happens when the bullet leaves the stage? (let alone hits something) we need to add a check to see if it's not needed anymore - if/when, we'll want to remove it, or else our whole program will get bogged down after we've shot a few hundred bullets and they're all still traveling off into lala land and processing their events... forever... - so we add a 'condition' and check for the 'end' of the stage:
if( e.currentTarget.x > stage.stageWidth ){
e.currentTarget.removeEventListener( Event.ENTER_FRAME, move );
removeChild( MovieClip(e.currentTarget) );
}
also note that we'll need to 'remove' the event listener so that it doesn't continue running (although we can get away with loose referenced listeners and the GC will get rid of it if there are no remaining instance refs - but it's best practice to remove it explicitly)
now, with those things in place we should be able to make the robot fire a bullet - so all together our code looks like this:
addEventListener( MouseEvent.CLICK, shoot );
function shoot( e:MouseEvent ):void {
var b:MovieClip = new Bullet();
b.x = robot.x + 20;
b.y = robot.y;
b.addEventListener( Event.ENTER_FRAME, move );
addChild( b );
}
function move( e:Event ):void {
e.currentTarget.x += 20;
if( e.currentTarget.x > stage.stageWidth ){
e.currentTarget.removeEventListener( Event.ENTER_FRAME, move );
removeChild( MovieClip(e.currentTarget) );
}
}
so this is very, VERY basic, our robot does nothing but stand in one place and when you click the mouse shoot a bullet to the right - that's all - there's a ton more to do to make it into a game, robot movement, bullets hitting things, enemies, scoring, effects, UI screens, etc. - much to do
so this probably doesn't make a whole lot of sense to you, i'm guessing, since many of the basic principles here are not being explained, but what it should tell you is that there is a lot of work to making games, and we haven't even begun to scratch the surface here. my suggestion is to start at the beginning, and read, do some more reading, then read some more - start with devouring the Flash 'getting started' section of the Help docs and then hit the thousands of Tutorials out there, and try some things, experiment and learn.