官术网_书友最值得收藏!

Animated pieces

We will define three different types of animated pieces: rotating, falling, and fading. The animation for each of these types will be accomplished by altering the parameters of the SpriteBatch.Draw() call.

Classes for animated pieces

In order to represent the three types of animated pieces, we will create three new classes. Each of these classes will inherit from the GamePiece class, meaning they will contain all of the methods and members of the GamePiece class but will add additional information to support the animation.

Tip

Child classes

Child classes inherit all of their parent's members and methods. The RotatingPiece class can refer to the _pieceType and _pieceSuffix of the piece, without recreating them within RotatingPiece itself. Additionally, child classes can extend the functionality of their base class, adding new methods and properties, or overriding old ones. In fact, Game1 itself is a child of the Micrsoft.Xna.Game class, which is why all of the methods we use (Update(), Draw(), LoadContent(), and so on) are declared with the Overrides modifier.

Let's begin by creating the class we will use for rotating pieces.

主站蜘蛛池模板: 辽宁省| 随州市| 衡水市| 班戈县| 赞皇县| 伊春市| 阿荣旗| 香港 | 九江县| 沙湾县| 彩票| 辉南县| 盐城市| 淮南市| 黑山县| 临西县| 千阳县| 玉门市| 宜都市| 甘泉县| 襄城县| 壶关县| 织金县| 潜江市| 区。| 古丈县| 桦甸市| 浑源县| 新丰县| 盐池县| 邢台市| 嵊州市| 芦山县| 大兴区| 南皮县| 南安市| 廉江市| 洪雅县| 伊宁县| 阳原县| 苏尼特左旗|