An example of an interesting action in response to a mouse attack

Source: Internet
Author: User
Tags insert rar
Mouse | Response recently found an interesting mouse example, try to achieve a bit, and found that its realization of the idea of what we do games such things are very valuable, so the process written down, hope for everyone useful.

   Download This example source file (rar compressed file, 278K)

Effect preview: ( Full Screen view)

Try to slap him with a mouse or give him a few feet.

first, the realization of ideas

We first look at the effect of the example, the mouse in the scene in different places across, the scene of the villain will have different responses. It is especially interesting that when the speed of the mouse is different, the reaction is different. This is similar to the implementation of the game.

In general, the realization of the idea is probably like this: first make a good mouse across different parts of the response to the action effects, and then use a few movie clip to capture the mouse across the position and speed, and then play different action effects, this is what we see the effect.

Second, the implementation process

Now let's look at the specific implementation process.

1, press "CTRL + N", create a new Flash file, press "CTRL + F8", create a new movie Clip, named "All Motion".

2, enter this movie Clip, right click on the name of the layer, insert "label", "Action", "sound", "idle" four layers, in the "label" layer of the first frame of the property panel to set the label "C_idle", Click the right mouse button on frame 34th, inserts a keyframe and sets the label for this frame to "Ml_w," in the same order, in 47th, 77th, 89th, 139th, 154th, 168th, No. 220, No. 255, No. 267, No. 310, No. 358 frames, Frame No. 372, insert a key frame on frame No. 430, frame No. 446, and set the frame label to "ml_s", "Mr_w", "mr_s", "Tl_m", "Tl_w", "tl_s", "Tr_m", "Tr_w", "tr_s", "B_m", "Bl_w", "bl_s", "Br_w", "br_s".

3, in the "Action" layer of the 33rd frame click on the right mouse button, insert a keyframe, in this frame of the Action script panel above add statements: gotoAndPlay (1); Similarly, the 46th frame, 75th frame, 85th frame, 120th frame, 151th frame, 165th frame, No. 205 frame, No. 252 frame, No. 266 frame, No. 301 frame, No. 357 frame, No. 369 frame, No. 420 frame, No. 440 frame, No. 464 frame are inserted into a keyframe. and add the statement above the action Script panel of the frame respectively: gotoAndPlay (1);

4. Insert a keyframe above the 34th frame of the "idle" layer, and draw a villain with the drawing tool in the scene in frame 1th of the layer, as shown in Figure 1. This is displayed when there is no mouse action.

Figure 1
5, in the "layer1" layer on the 34th and 45th frames, insert a key frame, between the 34th frame to 45th frame to create when the mouse at a slower speed from the left arm of the movie clip effect. And so on, between frames 34th to 45th, create a movie clip effect when the mouse is slowly moving from the left arm of a small person. Between frames 47th to 74th, the movie clip effect is produced when the mouse moves from the left arm of the person to a relatively fast speed. Create a movie clip effect on the right arm of the mouse at a slower speed between frames 77th through 84th. Between frames 89th to 119th, the movie clip effect is produced when the mouse moves from the right arm of a small person to a relatively fast speed.

6, between the 139th frame to the 150th frame to produce when the mouse to the middle of the speed from the left side of the head across the movie clip effect. Create a movie clip effect from the left head of the mouse at a slower speed between frames 154th to 164th. Between frames 168th to No. 204, the movie clip effect is produced when the mouse moves from the left head to the relatively fast speed. Create a movie clip effect between frames from frame No. 220 to No. 251 when the mouse is at a moderate speed from the right head of a small person. Create a movie clip effect between frames from frame No. 255 to No. 265 when the mouse is at a slower speed from the right head of a small person. Between frames No. 267 to No. 300, the movie clip effect is produced when the mouse moves from the right head to the relatively fast speed.

7, between the No. 310 frame to the No. 356 frame to produce when the mouse to the middle of the speed of the leg across the movie clip effect. Between frames No. 358 to No. 368, the movie clip effect is produced when the mouse is slowly moving from the left leg of a small person. Between frames No. 372 to No. 419, the movie clip effect is produced when the mouse moves from the left leg of the small person to a faster speed. Between frames No. 430 to No. 439, the movie clip effect is produced when the mouse moves from the right leg to a slower speed. Between frames No. 446 to No. 463, the movie clip effect is produced when the mouse moves from the right leg to a relatively fast speed.

8, at this point, the required movie clip on the production completed. The layer structure within the frame should be as shown in Figure 2. Note that this is the most time-consuming step, but also the ultimate effect of the most important step, it is worth the effort to do. If you want a better effect, you can insert the sound effect where appropriate.

Figure 2
9, press "Ctrl + F8" to create a new movie Clip, with drawing tools in this Clip to draw a semicircle.

10, back to the main scene of the film, the right mouse click on the layer name, insert 4 layers, named "Action", "Hit_area", "Motion_all", "label."

11, in the "Motion_all" layer 2nd frame Insert Keyframe, frame 7th frame, the 1th to 8th step of the movie clip from the gallery dragged to the scene, the property panel set instance name "Motion_all."

12, in the "Hit_area" layer 2nd frame Insert Keyframe, insert the frame in frame 7th, drag the 9th movie clip from the Gallery six times to the scene, spell a graphic as shown in Figure 3, and set the instance name "Area_head_left", "area" on the property panel, respectively. _arm_left "," Area_leg_left "," Area_head_right "," Area_arm_right "," Area_leg_right ".

Figure 3

13. Insert the keyframe at frame 2nd at the Action layer, and insert the frame at frame 7th, at which point the layer in the main scene should look like Figure 4. Click the 2nd frame of the "action" layer and add the statement below in the action Script panel of the frame.

Figure 4



Note 1: Define variables to determine whether the mouse is moving across the object in a slower, medium, and faster speed.
Note 2: Hides the object used to capture the mouse action.
Note 3: Initializes the mouse parameters.
Note 4: This function is used to capture the speed and the position of the mouse across.
Note 5: This function is used to determine the speed of the mouse across, respectively, strong, medium and weak.
Note 6: This function is to judge the position of the mouse, respectively, corresponding to the scene of the object's head, hands, feet.
Note 7: In this function, play the corresponding scene triggered by the mouse action.
Note 8: This is the starting function of the entire scene, the constant loop, constantly responding to the mouse action.

Third, summary

In general, the object in the scene in response to the mouse action, the corresponding mouse action triggers play the corresponding movie Clip. One of the movie Clip of the production of good or bad, the impact of the overall effect is very large, it is worth the heart to do a good job movie Clip.

   Download This example source file (rar compressed file, 278K)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.