Exemple #1
0
 public Sprite(Texture2D image, Vector2 position, Point frameSize,
         int collisionOffset, Point currentFrame, Point sheetSize, Vector2 velocity, float size)
 {
     currentAnimation = new Animation(image, frameSize, currentFrame, sheetSize);
     this.position = position;
     this.collisionOffset = collisionOffset;
     this.velocity = velocity;
     this.size = size;
 }
        /// <summary>
        /// Set and initialize animation if it's not already running
        /// </summary>
        /// <param name="animation"></param>
        public void setAnimation(Animation animation)
        {
            if (currentAnimation == animation)
                return;

            currentAnimation = animation;
            currentAnimation.Initialize();
        }
        // Load and initialize animations, sounds, etc...
        public override void Initialize(IServiceProvider serviceProvider)
        {
            IsAlive = true;

            ContentManager content = new ContentManager(serviceProvider, "Content");
            idle = new Animation(content.Load<Texture2D>(@"Images/Idle"), new Point(64, 64),
                                new Point(0, 0), new Point(1, 1));
            run = new Animation(content.Load<Texture2D>(@"Images/Run"), new Point(64, 64),
                                new Point(0, 0), new Point(10, 1));
            jump = new Animation(content.Load<Texture2D>(@"Images/Jump"), new Point(64, 64),
                                new Point(0, 0), new Point(11, 1), 70);
            die = new Animation(content.Load<Texture2D>(@"Images/Die"), new Point(64, 64),
                                new Point(0, 0), new Point(12, 1));
        }