Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Chúng tôi sẽ cần phải rút ra văn bản trên màn hình trò chơi bằng cách sử dụng bất kỳ font mong muốn, và các lớp đồ họa cho chúng ta khả năng này, thông qua dây kéo () chức năng. Có một số phiên bản của các chức năng với các bộ khác nhau của các thông số, | Drawing Text 29 random line ends int x rand.Next 1 this.Size.Width - 50 int y rand.Next 1 this.Size.Height - 50 Rectangle rect new Rectangle x y 50 50 draw the rectangle device.DrawRectangle pen rect refresh the drawing surface pb.Image surface private void timer_Tick object source EventArgs e drawRect Drawing Text We will need to draw text onto the game screen using any desired font and the Graphics class gives us this ability too via the DrawString function. There are several versions of the function with various sets of parameters but we will be using the simplest version that just needs a String for the words we want to print out a custom Font object the color and the coordinates. Figure 2.4 shows the result of this example program. using System using System.Drawing using System.Windows.Forms public partial class Form1 Form string text AVAtAR Know that Brittania has entered into a new age of enlightenment Know that the time has finally come for the one true Lord of Brittania to take his place at the head of his people. Under my guidance Brit- tania will flourish. And all of the people shall rejoice and pay homage to their new. guardian Know that you too shall kneel before me Avatar. 30 Chapter 2 Drawing Shapes and Bitmaps with GDI Text Drawing Demo AVATAR Know that Brittania has entered into a new age of enlightenment Know that the time has finally come for the one true Lord of Brittania to take his place at the head of his people. Under my guidance Brit-tania will flourish. And all of the people shall rejoice and pay homage to then new. guardian Know that you too shall kneel before me Avatar. You too will soon acknowledge my authority. For I shall be your companion. your provider. and your master Ultima VII The Black Gate Copyright 1992 by Electronic Arts Figure 2.4 Printing text using a custom font and color. You too will soon acknowledge my authority. For I shall be your companion. your provider. and your master Ultima VII The Black Gate Copyright 1992 by .