Make Marbel Texture..
Make variable colored grid..
Neon Text..
The micro bevel..
Rusted Type..
3D Text/Logo..
Techno-wave Effect..
Trendy Avatar..
Simple background..
Digital Effect..
Polar Coordinates..
Water drops..
LCD Screens..
Steel Type..
Pixelated Text..
Smooth Edges..
Vectorizing Photos..
Luminous Essence..
Transparency..
Digital Smoke..
Game cube logo..
Gradient Grids..
Sparkles..
Driping Slime..
Borders..
Cartoon Clouds..
Organic Tech..
Aqua Balls..
Kerning and Tracking text..
Getting rid of overlap..
Weaving a ribbon through text..
Blend layers w/ opacity mask..
Brilliant Color..
Create 3D Cylinder..
Creating Artistic Brushes..
Fine Lines Design..
Transition b/w two objects..
Distortion Effect..
Soft Proof your colors..
Knotworking..
Creating views..
Transforming shapes..
Creating Image map..
Optimizing web graphics..
Using Slice tool..
Creating web button..
Animation of scaling..
Ripple Animation..
Colors changes to animation..
Neon light animation..
Creating a Navigation bar..
Animated Imagemap Button..
Preloader with FlashMX..
Sound Control..
Steel Flash..
Using masks..
Loading an external movie..
Flash light effect..
Flash game techniques (P-1)..
Flash game techniques (P-2)..
Flash game techniques (P-3)..
Flash game techniques (P-4)..
Flash game techniques (P-5)..
Dropdown menu for FlashMX..
Zoom blur effect..
Dessolving words ..
Spotlight masking..
Passing variable to Flash..
Clear Text..
Create Time in Flash..
Change colors of movieclip..
Creating sites using CSS ..
Dreamweaver 4 Flash buttons..
Defining a site..
Dreamweaver Form tips..
Dreamweaver interface..
Creating nested tables..
Rollover form buttons..
Graphics Editing w/ DW & FW..
Inserting FW HTML into DW..
Working with templates..
Quick shapes in freehand..
Making a 3D pie-chart..
Exporting GIFs from Freehand..
Creating 3D Soccer Ball..
Creating Perspective shadows..
Chrome effect in Freehand..
Creating Hollow Envelopes..
Building Buttons..
Drawing a heart symbol..
3D Ball ..
Bouncing ball..
Automating Fireworks..
Text writing animation..
Fireworks 4 Popup menus..
Creating Gel Text..
Outline tool overview..
Cracked text..
Page curl ..
Contoured Text ..
Drop Shadows ..
Creating complex shapes..
Creating volumetric clouds..
Water/Fire/Smoke Effect ..
The Power of Radial array..
Modelling an Eye..
Welding vertices..
Animating a ball..
Realistic Texturing..
Polygon basics..
Lathe Tutorial ..
Emit geometry from a point emitter..
Creating a missile trail..
Animating a flying baloon..
Introduction to Expressions..
Making MEL Procedures..
Introduction to MEL Scripting..
Modeling a mechanical hand..
Build a spiral staircase..
Building leg skeletons..
Modeling a head..
Texturing the head..

How to make water ripple..
Create Ghost shader..
Using two bone IK Solver..
Using multi-texturing..

Flash Game - Part 4

Adding the scoring and timer to part 4of the tutorial.

Again, time to open up the old fla. Insert the layers "labels" and "score". The score layer will contain the score and timer, and the labels layer - well, the frame labels. The labels layer is more for easy navigation more than anything else, and it's a good idea to use frame labels when referring to points in your movie, as frame additions and subtractions, won't affect the location you're pointing to. In smaller movies it's not a problem but in larger movies, it can be. Anyway, this is what your layers should look like:

In frame 1 of the labels layer, insert a frame label "start". In frame 2 of the labels layer, press F7 to insert a blank key frame, then insert the label "done".

Click in the first frame of the score layer. In the top left corner of the stage, insert some "static" text saying "Score:", then a dynamic text box next to it, with the Var box set as "score" and the text alignment set to left. Then next to that dynamic text box insert some more static text saying "Time:" and next to that insert a dynamic text box with the Var box set to "counter" and the text alignment set to left:

In the actions layers, click in the first frame and press F9. This should bring up the actions window. There should only be a stop(); there. Underneath this, add:

score = 0;
speedy.resetSpeedy();

resetSpeedy(); resets Speedy when you play the game again. Make sure you have given Speedy the instance name "speedy". You have to use speedy.resetSpeedy(); because the function resetSpeedy() resides in the time line of the movie clip "speedy".

Now, bring up the actions for a character, for example, the gold one. Insert the actions that are in bold:

on (press) {
_root.score += 10;
this.gotoAndPlay("gold1shot");
this.enabled = 0;
}

This adds 10 to the score when you shoot him.

You have to say _root.score, because the score variable exists on the main time line - _root - , not in the time line of the gold character movie clip.

_root.score += 10 is the same as _root.score = _root.score + 10

Note this also works with strings:

var name = "Joe"
name += " Bloggs"

name is now "Joe Bloggs". You can use trace (name); to see the result.

Trace(); is used to display a variable or value, etc. while testing a movie.

If you see me sometimes declare a variable "explicitly" with var, eg:

var name = "Joe"

and sometimes "implicitly" or on the fly, eg:

name = "Joe"

then it's just my sloppy coding. You should try to explicitly declare variables with var as it is good practice, and can avoid certain problems. There are also times when you'd want to use var, for example in "for" loops where you would just want a temporary variable to store the count, etc. - but that's another story.

Add the same code for the remaining characters, except Speedy. For Speedy use _root.score += 50 because you get a bonus for shooting Speedy.

Now, click on the "counter" dynamic text box - you should now be in the score layer. Press F8 to Convert to Symbol. Select Movie Clip and give it the name "timer". Press F9 to bring up the actions window. Enter the following actions:

onClipEvent (load) {
start = getTimer();
startCount = 90;
}
onClipEvent (enterFrame) {
current = (getTimer()-start)/1000;
if (current<startCount) {
elapsed = startCount-current;
counter = Math.floor(elapsed);
} else {
_root.gotoAndStop("done");
}
}

There are various ways of doing a simple count down timer. This is one of them, based on one I saw by Colin Moock. Note, getTimer(); is a built in Flash function that gives you the number of milliseconds elapsed since the movie ran. Try creating a new file and in the first frame put:

trace(getTimer());

and in the second frame put:

gotoAndPlay(1);

then test your movie and you'll see the value returned by getTimer(); increment.

Explanation:

onClipEvent (load) {
start = getTimer();

Gets the value of getTimer(); when the clip loads

startCount = 90;
How much you want to count down from.

onClipEvent (enterFrame) {
current = (getTimer()-start)/1000;

Every frame, current equals the value of getTimer(); subtracted by the starting value of getTimer() (start) divided by 1000 - because the value is returned in milliseconds, you need to convert it to seconds. If you included trace(current) in your code, you'd see the value increment.

if (current<startCount) {
Although the value of current is incrementing, if it's below the startCount value (90) then:

elapsed = startCount-current;
Elapsed equals startCount - 90 - minus the value of current. If you trace(elapsed) you'd see it decreasing like 89.234, 88.127, etc.

counter = Math.floor(elapsed);
Counter - the variable the text box will show - is elapsed, rounded down so the values appear as 89, 88, 87, etc.

} else {
_root.gotoAndStop("done");
If current is not less than startCount (90) then go to the frame labeled "done" on the main time line and stop.

Now, click in frame 2 of the score layer and press F6 to insert a key frame. Delete the "Score:" text, the "Time:" text and the time dynamic text box.

In the centre of the screen enter some text saying "Time up. Your score was:", then underneath that, move the score dynamic text box. Make sure the text alignment for the dynamic text box in this frame, is centred.

Insert some text saying "Play Again", with a button underneath it:

Put these actions on the button:

on (release) {
_root.gotoAndPlay("start");
}

Now if you remember, earlier you added resetSpeedy(); to the actions in the main time line. When you click the button to replay the game - you want speedy to be reset - and the resetSpeedy(); in the onClipEvent(load) in Speedy's actions won't do it, as that only works once, when the clip is loaded. When you restart the game - you're not reloading the Speedy movie clip - it's already loaded - so the onClipEvent (load) actions won't be repeated.

You should have the scoring and the timer working. Next tutorial will be on making bullet holes when you shoot.

Partners

Flash Templates
Free Web Templates
FREE professional web templates
Website templates
Free Web Templates
Graphic Design
Tutorial Guide
Flash Templates

Flash Templates and Web Templates

 


Advertise | Submissions | Privacy Policy
All the contents and articles within this website are property of their respective authors and are submitted to us by them, we do not held any liability for the material including text and graphics submitted by them.
© Copyright Vecpix.com 2006-07. All rights reserved.

Partners network: