示例#1
0
        public Tank(Game game, SceneObjectParent parent,TileMap tileMap)
            : base(tileMap,parent,GetImage(game))
        {
            Texture2D tankTurretImage = game.Content.Load<Texture2D>(@"Textures/TankTurret");

            tankTurret = new BasicSprite(this, tankTurretImage);
            this.SetHandle(new Vector2(GetImage(game).Width / 2, GetImage(game).Height / 2));
            tankTurret.SetLocalPosition(new Vector2(GetImage(game).Width / 2, GetImage(game).Height / 2));
            tankTurret.SetHandle(new Vector2(7, 7));
            tankTurret.SetLocalRotation((float)Math.PI / 4);
            this.tileMap = tileMap;
        }
示例#2
0
 /// <summary>
 /// This is the constructor for a Tank object
 /// </summary>
 /// <param name="game">The Game to use to load the assets</param>
 /// <param name="parent">The parent scene object to make the tank
 /// a child of</param>
 /// <param name="tileMap">The tilemap to scroll when we get too close to an edge</param>
 public Tank(Game game, SceneObjectParent parent,TileMap tileMap)
     : base(tileMap,parent)
 {
     //Load the images of the tank body and turret
     Texture2D tankBodyImage = game.Content.Load<Texture2D>(@"Textures/TankBody");
     Texture2D tankTurretImage = game.Content.Load<Texture2D>(@"Textures/TankTurret");
     // Now make the tank body a basicSprite that is a child of the Tank
     tankBody = new BasicSprite(this, tankBodyImage);
     // Now make the tank turret a BasicSprite that is a child of the body
     tankTurret = new BasicSprite(tankBody, tankTurretImage);
     // set the rotation and translation origin of the tank body at its center
     tankBody.SetHandle(new Vector2(tankBodyImage.Width / 2, tankBodyImage.Height / 2));
     // set the turret's origin at the approximate center of the round part
     tankTurret.SetHandle(new Vector2(7, 7));
     // set the turret's position as being at the center of the tank
     tankTurret.SetLocalPosition(new Vector2(tankBodyImage.Width / 2, tankBodyImage.Height / 2));
     // save the tile map
     this.tileMap = tileMap;
 }