Đang chuẩn bị liên kết để tải về tài liệu:
Macromedia Flash MX Game Design Demystified phần 3

Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ

Chiếu từ trong bối cảnh lượng giác có nghĩa là dự án một số lượng (ví dụ như khoảng cách hoặc vận tốc) lên trục x và trục y. Sử dụng những gì bạn sẽ học trong phần này sẽ giúp bạn khi xây dựng trò chơi. Đối với một ví dụ về những gì chiếu, bạn có thể thực hiện, mở shooter.fla tập tin trong thư mục Chapter03 trên đĩa CD-ROM. | distance radíusl radius2 V x2-xl z y2-yl 2 Solving for the time is very difficult. We must insert the equations for x1 y1 x2 and y2. We then square both sides of the equation to get rid of the square root sign . What we are left with is a quadratic equation. Quadratic equations have two solutions which means that when we solve for the time we will get two answers. Conceptually we can see why in this case we will get two separate Imagine two circles moving toward each other. At one time they will be touching on an edge. As goes on they will move through each other but just as they are about to separate they will be exactly at one point again. The two times found by solving the quadratic equation give the two times that a collision can occur. When we have our two answers we look at the lower of the two times and discard the other one. By defining these constants R a b c d e f g h radius1 radius2 -2 xmov1 xmov2 xmov12 xmov22 -2 xl1 xmov2-2 xl2 xmov1 2 xl1 xmov1 2 xl2 xmov2 -2 xl1 xl2 xl12 xl22 -2 ymov1 ymov2 ymov12 ymov22 -2 yl1 ymov2-2 yl2 ymov1 2 yl1 ymov1 2 yl2 ymov2 -2 yl1 yl2 yl12 yl22 a d b e k c f-R2 we can write the vastly simplified quadratic equation as g t2 h t k 0 Using the quadratic formula to solve for the time we arrive at and 4. This calculation is performed for every frame. If either of the times is less than or equal to 1 then a collision happened between the previous frame and the current frame. This works for any possible velocity there is no limit. If you are interested in seeing this math worked out more rigorously check out circ_circ_frame_independent.pdf in the Chapter05 directory on the CD. It shows this worked out manually. Solving Quadratic Equations Any equation in which the variable has an exponent of 2 and no other terms with a higher exponent is a quadratic equation. For instance a t2 b t c 0 is a quadratic equation. All quadratic equations have two solutions this means there are two values for the variable for the equation is valid. The