コード例 #1
0
ファイル: Game1.cs プロジェクト: danielsbonnin/cscheckers
        // Store some information about the sprite's motion.
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);
            redCheckAnimated.Load(Content, "rCheckAnimated", Frames, FramesPerSec);
            rCheck     = Content.Load <Texture2D>("rChecker");
            wCheck     = Content.Load <Texture2D>("wChecker");
            rKing      = Content.Load <Texture2D>("rKing");
            wKing      = Content.Load <Texture2D>("wKing");
            rKing_H    = Content.Load <Texture2D>("rKingHighlight");
            wKing_H    = Content.Load <Texture2D>("wKingHighlight");
            rCheck_H   = Content.Load <Texture2D>("rCheckerHighlight");
            wCheck_H   = Content.Load <Texture2D>("wCheckerHighlight");
            background = Content.Load <Texture2D>("board");
            mainframe  = new Rectangle(0, 0, GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height);

            //for (int i = 0; i < 12; i++)
            //    redCheckers[i] = Content.Load<Texture2D>("rChecker");

            // TODO: use this.Content to load your game content here
        }
コード例 #2
0
        public Enemy(Vector2 enemyPosition)
        {
            Position         = enemyPosition;
            initialPosition  = enemyPosition;
            previousPosition = enemyPosition;

            initialDirection  = DirectionMap.DIRECTION_VECTORS[Direction.Down];
            MovementDirection = initialDirection;

            scream = PedestrianGame.Instance.Content.Load <SoundEffect>("Audio/scream");

            frontSprite = new AnimatedTexture();
            var frontAsset = PedestrianGame.Instance.Content.Load <Texture2D>("gremlin16bit02");

            frontSprite.Load(frontAsset, 2, 60);

            leftSprite = new AnimatedTexture();
            var leftAsset = PedestrianGame.Instance.Content.Load <Texture2D>("gremlin16bit-left01");

            leftSprite.Load(leftAsset, 2, 60);

            rightSprite = new AnimatedTexture();
            var rightAsset = PedestrianGame.Instance.Content.Load <Texture2D>("gremlin16bit-right01");

            rightSprite.Load(rightAsset, 2, 60);

            currentSprite = frontSprite;

            // Collides only with default and not other collider types
            Collider = new BoxCollider(ColliderCategory.Default, ColliderCategory.Default | ColliderCategory.GameBounds)
            {
                Position           = enemyPosition,
                Width              = frontSprite.FrameWidth - 3,
                Height             = frontSprite.FrameHeight - 1,
                OnCollisionEntered = OnCollisionEntered
            };
        }