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

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.

主站蜘蛛池模板: 潼南县| 南江县| 本溪市| 曲阳县| 布尔津县| 班戈县| 高唐县| 马边| 辽阳市| 东安县| 分宜县| 平塘县| 凤冈县| 通山县| 化州市| 松阳县| 乡宁县| 平定县| 阿合奇县| 板桥市| 眉山市| 津市市| 随州市| 绥滨县| 盘锦市| 仙桃市| 曲周县| 荥经县| 龙井市| 祁阳县| 仁布县| 杭锦旗| 盐亭县| 金湖县| 山阳县| 沾化县| 瑞丽市| 沧州市| 安远县| 赤水市| 镇江市|