示例#1
0
        //plays the passed in animation
        public void PlayAnimation(Animation animation)
        {
            // If this animation is already running, do not restart it.
               if (Animation == animation)
              return;

            // Start animation.
            this.animation = animation;
            this.frameIndex = 0;
            this.time = 0.0f;
        }
示例#2
0
        public Animation teleAnimation; //this holds the teleport animation

        #endregion Fields

        #region Methods

        public override bool Load(string assetName, Microsoft.Xna.Framework.Content.ContentManager content, FarseerGames.FarseerPhysics.PhysicsSimulator simulator)
        {
            teleAnimation = new Animation(content.Load<Texture2D>("portalv2"), 0.1f, true); //creates the animation. 0.1f is the time between frames and true means is looping

            currentTexture = content.Load<Texture2D>(assetName);
            origin = new Vector2((currentTexture.Height / 4) / 2, currentTexture.Height / 2);
            body = BodyFactory.Instance.CreateRectangleBody((currentTexture.Height / 4), currentTexture.Height, 1);
            geom = GeomFactory.Instance.CreateRectangleGeom(body, (currentTexture.Height / 4), currentTexture.Height);
            body.Position = position;
            body.Tag = this;
            geom.Tag = this;
            simulator.Add(body);
            simulator.Add(geom);
            animationPlayer.PlayAnimation(teleAnimation);//plays the teleport animation
            return true;
        }
示例#3
0
 public override bool Load(string assetName, Microsoft.Xna.Framework.Content.ContentManager content, FarseerGames.FarseerPhysics.PhysicsSimulator simulator)
 {
     quarkAnimation = new Animation(content.Load<Texture2D>("Sprites\\quark"), 0.1f, true); //quarkAnimation has 0.1 units between frames, and is looping
     currentTexture = content.Load<Texture2D>(assetName);
     origin = new Vector2(currentTexture.Width / 2, currentTexture.Height / 2);
     body = BodyFactory.Instance.CreateRectangleBody(currentTexture.Width, currentTexture.Height, 1);
     geom = GeomFactory.Instance.CreateRectangleGeom(body, currentTexture.Width / 9, currentTexture.Height);
     body.Position = position;
     body.Tag = this;
     geom.Tag = this;
     simulator.Add(body);
     simulator.Add(geom);
     this.geom.CollisionEnabled = false; // this object should not collide with other objects
     animationPlayer.PlayAnimation(quarkAnimation);//plays the quark animation
     return true;
 }
示例#4
0
        public Animation pickupAnimation; // the animation for the pickup

        #endregion Fields

        #region Methods

        public override bool Load(string assetName, Microsoft.Xna.Framework.Content.ContentManager content, FarseerGames.FarseerPhysics.PhysicsSimulator simulator)
        {
            currentTexture = content.Load<Texture2D>(assetName);
            pickupAnimation = new Animation(content.Load<Texture2D>("pickup"), 0.1f, true);
            origin = new Vector2((currentTexture.Width / 8) / 2, currentTexture.Height / 2);
            body = BodyFactory.Instance.CreateRectangleBody((currentTexture.Width / 8), currentTexture.Height, 1);
            geom = GeomFactory.Instance.CreateRectangleGeom(body, (currentTexture.Width / 8), currentTexture.Height);
            body.Position = position;
            body.Tag = this;
            geom.Tag = this;
            simulator.Add(body);
            simulator.Add(geom);
            animationPlayer.PlayAnimation(pickupAnimation);
            isAlive = true; //if boolean is true, it has no been picked up
            return true;
        }
示例#5
0
        public override bool Load(string assetName, Microsoft.Xna.Framework.Content.ContentManager content, FarseerGames.FarseerPhysics.PhysicsSimulator simulator)
        {
            currentTexture = content.Load<Texture2D>(assetName);

            bouncyAnimation = new Animation(content.Load<Texture2D>("sprites//bouncing platform2"), 0.1f, true);
            origin = new Vector2((currentTexture.Width / 5) / 2, currentTexture.Height / 2); // width is devided by 5 due to 5 frames on the spritesheet
            body = BodyFactory.Instance.CreateRectangleBody((currentTexture.Width / 5), currentTexture.Height, 1);
            geom = GeomFactory.Instance.CreateRectangleGeom(body, (currentTexture.Width / 5), currentTexture.Height);
            body.Position = position;
            body.Tag = this;
            geom.Tag = this;

            simulator.Add(body);
            simulator.Add(geom);
            animationPlayer.PlayAnimation(bouncyAnimation); //initial animation for the bouncy tile
            return true;
        }
示例#6
0
        public override bool Load(string assetName, Microsoft.Xna.Framework.Content.ContentManager content, FarseerGames.FarseerPhysics.PhysicsSimulator simulator)
        {
            currentTexture = content.Load<Texture2D>(assetName);
            //varius animations, the units between each frame, and whether they are repeating (true)
            runAnimation = new Animation(content.Load<Texture2D>("Run"), 0.1f, true);
            idleAnimation = new Animation(content.Load<Texture2D>("still"), 0.1f, false);
            jumpStillAnimation = new Animation(content.Load <Texture2D>("JumpStill"), 0.1f, false);
            jumpRunAnimation = new Animation(content.Load<Texture2D>("runJump"), 0.05f,true);
            origin = new Vector2(42 / 2, 76 / 2);
            body = BodyFactory.Instance.CreateRectangleBody(42, 76, 1);
            geom = GeomFactory.Instance.CreateRectangleGeom(body, 42, 76);
            body.Position = position;
            body.Tag = this;
            geom.Tag = this;
            simulator.Add(body);
            simulator.Add(geom);
            Body.MomentOfInertia = 9999999999;  //Stops player from spinning and landing on his head
            body.LinearDragCoefficient = 10;  //air resistance (effects  jump behaviour)

            return true;
        }