tailieunhanh - Detecting Collisions

Phát hiện nhiều vụ va chạm Flash ứng dụng, đặc biệt là trò chơi, có thể phát hiện đối tượng va chạm-một trong những ứng dụng dễ dàng nhất hiểu của logic có điều kiện. Để phát hiện va chạm giữa hai đối tượng (phim trường clip) | Detecting Collisions Many Flash applications especially games are able to detect object collisions one of the most easily understood applications of conditional logic. To detect collisions between two objects movie clip instances ActionScript provides the hitTest method of the MovieClip class. Using this method in conjunction with a conditional statement allows you to take action when two movie clips collide. You define in the script the various actions you want to take depending on which object is hit. Take a look at the following script function if hitTest wallOfCotton_mc pain 0 else if hitTest wallOfCardboard_mc pain 5 else if hitTest wallOfBricks_mc pain 10 If the movie clip instance to which this event handler is attached myBody_mc collides with the movie clip instance named wallOfCotton_mc pain is set to 0. If myBody_mc collides with wallOfCardboard_mc pain is set to 5. Finally if myBody_mc collides with wallOfBricks_mc pain is set to 10. The hitTest method is very straightforward. In the following exercise we use the hitTest method in conjunction with a conditional statement to take specific action if the rocket_mc movie clip instance collides with either of the two red bars the launch window that are in motion. If the rocket hits either bar the launch aborts if the rocket passes through the space between the bars the launch is successful. 1. Open . This step builds on the file you worked with in the preceding exercise. 2. Double-click launchWindow_mc at the top of the stage to edit this clip in place. This movie clip instance contains other two movie clip instances the red bars with one flipped horizontally in the opposite direction of the other. The red bar on the left is named leftGuide_mc and the one on the right is named rightGuide_mc. Because both of these bars are movie clip instances you can use them to react to a collision with the rocket_mc movie clip instance. 3. Return to the main timeline. With the Actions

crossorigin="anonymous">
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.