Macromedia Flash MX Game Design Demystified phần 2

Dòng 1 đặt một đầu vào biến được gọi với giá trị là 0,707. Dòng 2 sử dụng phương pháp sin nghịch đảo của các đối tượng toán học (trong đó trả về một góc trong radian) và sau đó chuyển đổi nó đến mức độ. Kết quả là truy tìm trong cửa sổ và nên được rất gần đến 45 °. (Nó không phải là chính xác 45 ° | convince yourself of how this works try this example in Flash input .707 trace input 180 Line 1 sets a variable called input with a value of .707. Line 2 uses the inverse sine method of the Math object which returns an angle in radians and then converts it to degrees. The result is traced in the window and should be very close to 45 . It is not exactly 45 because the true sine of 45 has many more decimal places than .707. Projection The word projection in the context of trigonometry means to project a quantity such as distance or velocity onto the x-axis and y-axis. Using what you ll learn in this section will help you when building games. For an example of what projection can you accomplish open the file in the Chapter03 folder on the CD-ROM. In this file a ship rotates to point toward your mouse. When you click anywhere on the movie s stage a projectile fires from the nose of the ship. The velocity of the points toward your mouse or at least to the place where your mouse was when you clicked it . In order for this movement to be programmed in Flash the velocity must projected along the x-axis and y-axis. OThe programmatic movement seen in this example file is not covered until Chapter Basic Physics. Imagine a diagonal line of length len drawn in Flash at angle ang. A piece of this line extends along the x-axis and another piece of it along the -axis. If the angle were 0 then the line would extend only along the x-If the angle were 90 then the line would extend only along the -axis. With any other angle the line both in the x direction and the direction. Put another way no two coordinates on the line have the same x value A horizontal line always has the same value for all of its coordinates. A vertical line always has the same x value for all of its coordinates. A diagonal line never repeats an x or coordinate. If you were to a right triangle from this diagonal line then the two other sides of that triangle would be the pieces that .

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
Đã 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.