nih disini ada tutorial membuat flash platform game character follower
In this tutorial you will learn how to create a platform game with a jumping an walking system, and the ability to make npc like objects follow you through the game, using the efficiency of external actionScript (2.0) files by using classes. Step 1: Create a folder in which you want to save your files. Next, in Flash, create 1 flash file (AS 2.0), and 4 actionScript files. Save the flash file as "game". Save the actionScript files as the following: "character" (in this file we will write the code needed to control the character) "follower" (in this file we will write the code needed to control the follower) "follower_0" (in this file we will set variables for follower number one) "follower_1" (in this file we will set variables for follower number two)
Step 2: In the "character" file, write or paste this code: class character extends MovieClip { I don't feel like actually explaining this code, because it kind of speaks for itself, and if you know actionScript a little, this shouldn't be a problem at all... Next, save the file.
Step 3: In the "follower" file, write or paste this code: class follower extends MovieClip { As will become usual; save the file.
Step 4: In the "follower_0" file, put the following code: class follower_0 extends follower { Save the file. In the "follower_1" file, put the following code: class follower_1 extends follower { And again, save the file.
Step 5: Ok, was all of the codes, so now open your "game" file. Create 2 layers, and name them "character" and "bounds". Inside the 1st frame of your "character" layer, draw 3 objects that you wish to have as a character, and as followers. A square would do fine. Convert one square to a movie clip (hotKey is F8), and make sure you set the align to bottom. Next, tick the box of 'export for actionScript' and make sure the identifier and class names are both set to "character". Set the character's instance name to "char". Convert the next square to a movie clip, tick the box to 'export for actionScript' and set the identifier and class names are both set to "follower_0". Set the follower's instance name to "follower0". Convert the next square to a movie clip, tick the box to 'export for actionScript' and set the identifier and class names are both set to "follower_1". Set the follower's instance name to "follower1". In your "bounds" layer, simply create a horizontally stretched rectangle, convert it to a movie clip, and set it's instance name to "ground". Make sure your "ground" bound is below your character and followers, because otherwise they would keep falling on and on... If you test your movie now, it should work.
|