Esempio n. 1
0
        public AnimationScreen(SpriteBatch b)
            : base(b, Color.DarkRed)
        {
            Name = "AnimatedScreen";

            //SpriteSheet: Allows for animation with a single sprite sheet
            //FrameCollection: A collection of frames
            animated = new SpriteSheet(Vector2.Zero, b,
                                       FrameCollection.FromSpriteSheet(GLibXNASampleGame.Instance.Content.Load <Texture2D>("TestSpritesheet"),
                                                                       new Rectangle(99, 11, 45, 44),
                                                                       new Rectangle(150, 9, 45, 46),
                                                                       new Rectangle(198, 9, 45, 45),
                                                                       new Rectangle(252, 8, 45, 44),
                                                                       new Rectangle(303, 9, 45, 46),
                                                                       new Rectangle(351, 7, 45, 46),
                                                                       new Rectangle(396, 8, 45, 46),
                                                                       new Rectangle(444, 9, 45, 46),
                                                                       new Rectangle(495, 8, 45, 45),
                                                                       new Rectangle(552, 7, 45, 45)));

            animated.UseCenterAsOrigin = true;
            animated.Position          = animated.GetCenterPosition(b.GraphicsDevice.Viewport);
            //FrameTime: The amount of time to spend on each frame
            animated.Frames.SetTimeAll(TimeSpan.FromMilliseconds(50));
            //FrameChanged: An event fired upon frame change
            animated.FrameChanged += new EventHandler(animated_FrameChanged);

            AdditionalSprites.Add(new HitboxVisualizer(animated, b));
            Sprites.Add(animated);
        }
Esempio n. 2
0
        //SpriteSheet drawnSpriteSheetAnimate = null;

        void arrow_Updated(object sender, EventArgs e)
        {
            MouseState current = Mouse.GetState();

            if (!old.HasValue)
            {
                old = Mouse.GetState();
            }
            if (!isSelecting)
            {
                //((Sprite)sender).Rotation.Degrees += 0.5f;
                ((Sprite)sender).FollowMouse();
            }
            else
            {
                Sprite     active = ((Sprite)sender);
                MouseState ms     = Mouse.GetState();
                active.Rotation          = new SpriteRotation();
                active.Position          = new Vector2(25);
                active.UseCenterAsOrigin = false;
                Vector2 mousePos = new Vector2(ms.X, ms.Y);
                if (active.ClickCheck(ms) && !relativeSelectStart.HasValue)
                {
                    relativeSelectStart = mousePos;
                    arrows.AddNewSprite(relativeSelectStart.Value, Content.Load <Texture2D>("dot"));
                }
                if (active.Intersects(mousePos) && relativeSelectStart.HasValue && old.Value.LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed && current.LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Released)
                {
                    Texture2D use = arrows[0].Texture;
                    arrows.Clear();
                    arrows.Add(new SpriteSheet(new Vector2(25), spriteBatch, FrameCollection.FromSpriteSheet(use, new Point(Convert.ToInt32(mousePos.X - relativeSelectStart.Value.X), Convert.ToInt32(mousePos.Y - relativeSelectStart.Value.Y)))));
                    arrows[0].Updated          += new EventHandler(arrow_Updated);
                    arrows[0].UseCenterAsOrigin = true;
                    isSelecting = false;
                }
            }
            old = Mouse.GetState();
        }