TAILIEUCHUNG - Học Actionscript 3.0 - p 19

Simple Physics Simple Physics In the quest for more expressive animation, you will find that adding physics to animations, games, and similar projects can really elevate them to another level of user enjoyment. The visual appearance and, in interactive scenarios, even the user experience of a project are sometimes dramatically enhanced by surprisingly small code additions. We’re going to be discussing some basic physics principles in this section, but it’s more important for you to understand their effects than to focus minutely on the math and science behind them. This is because the formulas offered here are necessarily simplified, or even adapted,. | Simple Physics Simple Physics In the quest for more expressive animation you will find that adding physics to animations games and similar projects can really elevate them to another level of user enjoyment. The visual appearance and in interactive scenarios even the user experience of a project are sometimes dramatically enhanced by surprisingly small code additions. We re going to be discussing some basic physics principles in this section but it s more important for you to understand their effects than to focus minutely on the math and science behind them. This is because the formulas offered here are necessarily simplified or even adapted from their real-world counterparts. Once you re comfortable with the principles in general you can refine formulas account for additional variables and so on to improve their realism. For example it s often helpful to first simulate the simple orbit of a planet before considering the orbit s decay the gravitational attraction of other bodies and so on. Gravity What happens when you toss a ball into the air It goes up starts to slow down as gravity affects its rate of ascent it stops momentarily at the top of its journey and then the ball starts moving faster again as gravity starts to accelerate its trip downward. If you think about it carefully a simple ActionScript simulation of gravity requires little more than acceleration in the y direction. The following code found in the source file requires only minor changes to the previous acceleration example. Here we ll focus on acceleration in the y direction and we ll start with a negative y velocity to start the ball moving upward 1 var ball MovieClip new Ball 2 100 3 addChild ball 4 5 var xVel Number 4 6 var yVel Number -10 7 var yAcc Number 1 8 9 addEventListener onLoop false 0 true 10 function onLoop evt Event void 11 xVel 12 yVel 13 14 yVel yAcc 15 The ball begins moving at 10 pixels per enter frame event but .

TÀI LIỆU MỚI ĐĂNG
TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã 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.