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

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.

主站蜘蛛池模板: 新晃| 招远市| 旬邑县| 开鲁县| 安乡县| 东城区| 依安县| 云霄县| 新津县| 大足县| 曲靖市| 美姑县| 昌吉市| 灵武市| 浮山县| 宁安市| 颍上县| 古田县| 南召县| 应城市| 古田县| 郎溪县| 扎赉特旗| 杭锦后旗| 磐石市| 郓城县| 麻栗坡县| 河池市| 诸暨市| 杭锦后旗| 勐海县| 寿光市| 奎屯市| 木兰县| 钦州市| 额济纳旗| 曲水县| 抚松县| 洞口县| 北辰区| 康定县|