1

スプライトのアニメーションを表示するロジックを追加しましたが、画面に表示されません。私は何を間違っていますか?

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input.Touch;

namespace MyXNAGame.Game_Classes
{
  public class Player : Sprite
  {
    private int _frameCount = 6;
    private int _frameIndex;
    private Rectangle[] _frames;
    public float _jumpVelocity = 12f;
    public PlayerState _playerState;

    public Rectangle BoundingBox
    {
        get { return new Rectangle {X = (int) Position.X, Y = (int) Position.Y, Height = Texture.Height, Width = Texture.Width}; }
    }

    public void Initialize()
    {
        _frames = new Rectangle[_frameCount];
        int width = Texture.Width / _frameCount;
        for (int i = 0; i < _frameCount; i++)
        {
            _frames[i] = new Rectangle(i*width, 0, width, Texture.Height);
        }
    }

    public void Load(ContentManager contentManager, string assetName)
    {
        Texture = contentManager.Load<Texture2D>(assetName);
    }

    public void Update(GameTime gameTime)
    {
        while (TouchPanel.IsGestureAvailable)
        {
            GestureSample gestureSample = TouchPanel.ReadGesture();
            if (gestureSample.GestureType == GestureType.Tap)
            {
                if (_playerState == PlayerState.Running)
                {
                    _playerState = PlayerState.NormalJump;
                }
            }
            if (gestureSample.GestureType == GestureType.Hold)
            {
                if (_playerState == PlayerState.Running)
                {
                    _playerState = PlayerState.LongJump;
                }
            }
        }

        // NormalJump Logic
        switch (_playerState)
        {
            case PlayerState.NormalJump:
                Position.Y -= _jumpVelocity;
                _jumpVelocity -= 0.5f;
                if (_jumpVelocity == 0)
                {
                    _playerState = PlayerState.Falling;
                }
                break;
            case PlayerState.LongJump:
                Position.Y -= _jumpVelocity;
                _jumpVelocity -= 0.5f;
                if (_jumpVelocity == 0)
                {
                    _playerState = PlayerState.Falling;
                }
                break;
            case PlayerState.Falling:
                Position.Y += _jumpVelocity;
                _jumpVelocity += 0.5f;
                break;
            case PlayerState.Running:
                _frameIndex++;
                if (_frameIndex > 5)
                {
                    _frameIndex = 0;
                }

                break;
        }
    }

    public void Draw(SpriteBatch spriteBatch)
    {
        spriteBatch.Draw(Texture, Position, _frames[_frameIndex], Color.White, 0, new Vector2(0, 0), new Vector2(0, 0), SpriteEffects.None, 0);
    }
}

}`

誰でも明らかな間違いを見ることができますか?WP7を使用しています

4

1 に答える 1

1

Draw() メソッドの 'Scale' パラメータを new Vector(0,0) から new Vector(1,1) に変更しました。明らかに、Scale を 0 にすると何も表示されません。

于 2013-03-24T02:44:26.240 に答える