tailieunhanh - Beginning XNA 2.0 Game Programming From Novice to Professional phần 3

So sánh hai con số để hiểu làm thế nào sự khác biệt này ảnh hưởng đến định nghĩa "đỉnh cao hơn đỉnh một xuất hiện trên màn hình, phối hợp Y của nó thấp hơn. Tất cả những gì bạn cần làm bây giờ là rà soát lại các phương pháp cập nhật của lớp Game1 gọi không đồng bộ mới phương pháp tìm kiếm phiên, bằng cách bao gồm các dòng sau: | 64 CHAPTER 3 CREATING YOUR FIRST 2-D GAME Shake Baby Your game is almost ready. Now let s add one more effect to the game the vibration. When players collide with a meteor in addition to the explosion sound you ll make the Xbox 360 gamepad vibrate so they can feel the collision impact. As you saw in the previous chapter you can start and finish the Xbox 360 gamepad vibration through the SetVibration method. You re going to create a nonvisual GameComponent that will help you with this effect. So add a new GameComponent to the project as usual and add the following code region Using Statements using System using using using endregion namespace FirstGame summary This component helps shake your Xbox 360 gamepad summary public class SimpleRumblePad private int time private int lastTickCount public SimpleRumblePad Game game base game summary Allows the game component to update itself. summary param name gameTime Provides a snapshot of timing values. param public override void Update GameTime gameTime if time 0 int elapsed - lastTickCount if elapsed time time 0 CHAPTER 3 CREATING YOUR FIRST 2-D GAME 65 0 0 gameTime summary Turn off the rumble summary protected override void Dispose bool disposing 0 0 disposing summary Set the vibration summary param name Time Vibration time param param name LeftMotor Left Motor Intensity param param name RightMotor Right Motor Intensity param public void RumblePad int Time float LeftMotor float RightMotor lastTickCount time Time LeftMotor RightMotor In this class the RumblePad method receives the amount of time that the controller should stay vibrating and the vibration motor s intensity as parameters. So also as usual declare it .

TỪ KHÓA LIÊN QUAN
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.