public override void LoadContent()
        {
            base.LoadContent();

            World.Gravity = Vector2.Zero;

            _border = new Border(World, Lines, Framework.GraphicsDevice);
            for (int i = 0; i < 3; i++)
            {
                _breakableCookie[i]                   = Framework.Content.Load <BodyContainer>("Pipeline/BreakableBody")["Cookie"].CreateBreakable(World);
                _breakableCookie[i].Strength          = 120f;
                _breakableCookie[i].MainBody.Position = new Vector2(-20.33f + 15f * i, -5.33f);
            }

            _breakableSprite = new List <Sprite>();
            List <Texture2D> textures = ContentWrapper.BreakableTextureFragments(_breakableCookie[0], "Cookie");

            for (int i = 0; i < _breakableCookie[0].Parts.Count; i++)
            {
                AABB      bounds;
                Transform transform;
                _breakableCookie[0].Parts[i].Body.GetTransform(out transform);
                _breakableCookie[0].Parts[i].Shape.ComputeAABB(out bounds, ref transform, 0);
                Vector2 origin = ConvertUnits.ToDisplayUnits(_breakableCookie[0].Parts[i].Body.Position - bounds.LowerBound);
                _breakableSprite.Add(new Sprite(textures[i], origin));
            }
            _completeSprite = new Sprite(ContentWrapper.GetTexture("Cookie"), Vector2.Zero);
        }
        public override void LoadContent()
        {
            base.LoadContent();

            World.Gravity = Vector2.Zero;

            _border = new Border(World, LineBatch, Framework.GraphicsDevice);

            BodyContainer bodyContainer = Framework.Content.Load <BodyContainer>("Pipeline/BreakableBody");
            BodyTemplate  bodyTemplate  = bodyContainer["Cookie"];

            if (!_isLoaded) //we flip vertices once.
            {
                foreach (FixtureTemplate f in bodyTemplate.Fixtures)
                {
                    var shape = (PolygonShape)f.Shape;
                    shape.Vertices.Scale(new Vector2(1f, -1f)); // flip Vert
                    shape.Vertices.Translate(new Vector2(-5.33f, 5.33f));
                }
                _isLoaded = true;
            }

            for (int i = 0; i < 3; i++)
            {
                List <Shape> shapes = new List <Shape>();
                foreach (FixtureTemplate f in bodyTemplate.Fixtures)
                {
                    shapes.Add(f.Shape);
                }
                _breakableCookie[i] = new tainicom.Aether.Physics2D.Common.PhysicsLogic.BreakableBody(World, shapes);

                _breakableCookie[i].Strength          = 120f;
                _breakableCookie[i].MainBody.Position = new Vector2(-15.0f + 15f * i, 0f);
            }

            _breakableSprite = new List <Sprite>();
            List <Texture2D> textures = ContentWrapper.BreakableTextureFragments(_breakableCookie[0], "Cookie", 24f);

            for (int i = 0; i < _breakableCookie[0].Parts.Count; i++)
            {
                AABB      bounds;
                Transform transform;
                _breakableCookie[0].Parts[i].Body.GetTransform(out transform);
                _breakableCookie[0].Parts[i].Shape.ComputeAABB(out bounds, ref transform, 0);
                Vector2 origin = 24f * (_breakableCookie[0].Parts[i].Body.Position - bounds.LowerBound);
                _breakableSprite.Add(new Sprite(textures[i], origin));
            }
            _completeSprite = new Sprite(ContentWrapper.GetTexture("Cookie"));
        }
예제 #3
0
        public override void LoadContent()
        {
            base.LoadContent();

            World.Gravity = Vector2.Zero;

            for (int i = 0; i < 3; i++)
            {
                VerticesContainer  verticesContainer = Framework.Content.Load <VerticesContainer>("Pipeline/BreakableBody");
                List <VerticesExt> def = verticesContainer["Cookie"];
                _breakableCookie[i]                   = CreateBreakable(def);
                _breakableCookie[i].Strength          = 120f;
                _breakableCookie[i].MainBody.Position = new Vector2(-20.33f + 15f * i, -5.33f);
            }

            _breakableSprite = new List <Sprite>();
            List <Texture2D> textures = ContentWrapper.BreakableTextureFragments(_breakableCookie[0], "Cookie");

            for (int i = 0; i < _breakableCookie[0].Parts.Count; i++)
            {
                _breakableCookie[0].Parts[i].Body.GetTransform(out Transform transform);
                _breakableCookie[0].Parts[i].Shape.ComputeAABB(ref transform, 0, out AABB bounds);