Пример #1
0
 public object Clone()
 {
     Animation animationClone = new Animation(this);
     animationClone.frames = this.frames;
     animationClone.frameWidth = this.frameWidth;
     animationClone.frameHeight = this.frameHeight;
     animationClone.Reset();
     return animationClone;
 }
Пример #2
0
 // if we want to change the animation
 private Animation(Animation animation)
 {
     this.frames = animation.frames;
     FramesPerSecond = 5;
 }
Пример #3
0
        protected override void Load()
        {
            // TODO: Test worked, no just put it to use content pipeline

            // Load each tile used in map and ask for a TileList
            TileLoader loader = new TileLoader("Content/XMLmap/testi.xml", Engine.Content);
            TileList list = loader.GetTileList();

            // Load all the layers from file and ask for a maplayer list
            LayerLoader layerLoader = new LayerLoader("Content/XMLmap/layertesti.xml", list);
            List<MapLayer> layers = layerLoader.GetLayerList();

            tileEngine = new TileEngine(32, 32, Engine.GameRef);

            // Make map with all those layers
            Session.CurrentMap = new TileMap(layers);

            // Add components and controls etc
            animations = new Dictionary<AnimationKey, Animation>(); ;
            Texture2D playerTexture = Engine.Content.Load<Texture2D>("content/Sprites/malefighter");
            Animation animation = new Animation(3, 28, 28, 0, 0);
            animations.Add(AnimationKey.Down, animation);
            animation = new Animation(3, 28, 28, 0, 28);
            animations.Add(AnimationKey.Left, animation);
            animation = new Animation(3, 28, 28, 0, 56);
            animations.Add(AnimationKey.Right, animation);
            animation = new Animation(3, 28, 28, 0, 84);
            animations.Add(AnimationKey.Up, animation);
            playerSprite = new AnimatedSprite(playerTexture, animations);
            playerSprite.IsAnimating = true;

            AddComponent(playerSprite);

            SpriteFont spriteFont = Engine.Content.Load<SpriteFont>("Content/Fonts/Georgia");

            Label text = new Label(spriteFont, Engine.SpriteBatch);
            text.Text = "HakaGame 1.0";
            text.Size = spriteFont.MeasureString(text.Text);
            text.Position = new Vector2(100, 100);
            Controls.Add(text);
            base.Load();
        }