PDA

View Full Version : help with shootemup game


cheezisgoooood
10-01-2003, 03:51 PM
I'm making a shooting game and I've got alot done on it. In one of the movie clips when it comes to a certain frame I want it to play another movie clip on the stage. How do I do that?

dzy2566
10-01-2003, 03:59 PM
Use absolute paths.

//clip1 frame 10
_root.clip2.gotoAndPlay(2);

//clip2 frame 1
onClipEvent(load){
stop();
}

cheezisgoooood
10-01-2003, 04:12 PM
wow that was fast....but that still doesn't solve my problem. Let me tell you exactly what I'm doing. The first movieclip is a guy shooting the player. There is a frame where it shows the guy firing towards the screen. When it comes to that frame I want the life meter on the bottom to play, but I don't want it to gotoandplay a certain frame because if the guy shoots at the screen twice I want the life meter to be past that frame and on the frame where it says just one life is left because there are only three lives. So whenever the movieclip loops and goes to that frame where the guy is shooting the screen it will take away one life and there are 4 frames where the first one has all three lives, the second has two lives, the 3rd has one, and the last has none and then on the last frame it goes to a certain frame on the main stage that says game over. Can you help me with that?

cheezisgoooood
10-01-2003, 04:14 PM
The only thing I need help with is that one frame where it plays the life meter movie clip that's all I need help with not any of that other stuff.

dzy2566
10-01-2003, 04:28 PM
Might I suggest something a little more dynamic? Now keep in mind, this AS looks way more complicated than it really is. All the createEmptyMovieClip and drawingAPI can be done at authoring time w/o AS. I just did it this way so that you could cut and paste. To make yours, you would just draw a clip with a border layer and a lifeBar on a layer under that. Make sure the lifeBar has a registration point at the absolute left of it too, because we're scaling against the left side. Anyway, take a look at this code. The point of this is to avoid your goto problem. With this you can simply set the position of the life meter with a function whenever you need to.life = _root.createEmptyMovieClip("life",1);
life.createEmptyMovieClip("lifeBorder",3);
life.lifeBorder.lineStyle(5,0x666666,100);
life.lifeBorder.lineTo(100,0);
life.lifeBorder.lineTo(100,20);
life.lifeBorder.lineTo(0,20);
life.lifeBorder.lineTo(0,0);
bar = life.createEmptyMovieClip("lifeBar",2);
bar.lineStyle(2,0x000000,100);
bar.beginFill(0xff0000,100);
bar.lineTo(100,0);
bar.lineTo(100,20);
bar.lineTo(0,20);
bar.lineTo(0,0);
bar.endFill();
function sizeBar(path,life){
// assume full life is 100
path._xscale = life;
// set variables that actually control life here or do anything
// else you want to when the life changes, remeber this is
// only graphical
}
sizeBar(_root.life.lifeBar,50);
In the sizeBar function, the second argument controls the life. 50 is half, 100 is full, 0 dead, etc. I'm sure there will be questions, so just holla. I'll be here for a bit.

dzy2566
10-01-2003, 04:33 PM
Here's that mess built at authoring time. Remember, I have it built so the life directly corresponds to the life bar. If that's not the case, like you said you have 3 stages. Then you want _xscale = life/3, not simply _xscale = life. So now you would only enter 3, 2, 1, or 0. I think that the less author-time tweens you use, the better.

cheezisgoooood
10-01-2003, 04:55 PM
I am just a beginner and don't have one clue what your talking about after all this is the newbies forum. The code I have on the frame where it will play the life meter movie clip is this

life meter.play();

plain and simple and not working. All I want to do is make the life meter movie clip play when it reaches the frame where the guy is shooting the screen!!!!

dzy2566
10-01-2003, 05:09 PM
Yes, I understand what you've done. I'm saying you shouldn't be using a movie clip that plays. It would be easier to have a clip that can be changed with a function. Did you check out the attachment I gave you? It is very basic. Play with that a little bit. This solution side-steps your play() problems, because there is no play. No need to get upset. We're all willing to help, but you have to be willing to do some work with us too. We don't know exaclty what your abilities are. Try to play with it and come back with questions a little more specific than "I have no clue.....". I and the other members are more than happy to help.

dzy2566
10-01-2003, 05:15 PM
Function description:

When you call the size bar function in the following way:

sizeBar(_root.life.lifeBar,50);

In english, you are saying......

"Scale the clip 'lifeBar', which is inside the clip 'life' to 50%. In your case, you've been trying to get a clip with multiple frames to go to the frame that represents 50% health. In this example, there are no frames, so there's no confusion. Rather than having to go through the thought process of.....

"At this point in the game the player should have 50% of his life, which means my life meter clip should go to frame 4"

All you have to do is set the clip to look like whatever you want by passing the clip the scale, throught sizeBar.

"At this point in the game the player should have 50% health, so I have to tell the clip to display 50% health, or sizeBar(_root.life.lifeBar,50)

I hope that helps. If you're trying to build a game, these are very fundamental AS concepts that you will need to do it. So if this frustrates you or seems difficult I suggest trying to understand it rather than trying to get around it. If I can help more, please ask. I'm glad to do so.

cheezisgoooood
10-01-2003, 06:54 PM
it's not really a bar of life it's 3 little glowing squares. Each time you are hit it takes away one it's not a Life bar.

Xenozip
10-01-2003, 10:01 PM
Originally posted by cheezisgoooood
it's not really a bar of life it's 3 little glowing squares. Each time you are hit it takes away one it's not a Life bar.
:rolleyes:
Then make the "Life meter" a single MC, and each time you get hit, have flash advance to the next frame of the "Life meter" MC, where each frame has one less glowing square than the last. Once the Lifebar MC has reached the last frame, the player is obviously dead, so make it tell level0 to display a "you died" screen, or what have you.

To do this, do what dzy2566 said: Use absolute paths.

cheezisgoooood
10-03-2003, 08:34 PM
DUH!!!! that's what I'm asking about!!! pay attention!!! I just want to know a simple piece of code to do that k?

Cannon2004
07-30-2004, 03:54 PM
He wants to make one box dissapear when he looses a life. Something like
object.visible=true ( thats the visual basic code for it but its similar to what you want, i know that VB code wont work in flash, its just an example)