Aiv.Fast2D.Example.Rope.SetDestination C# (CSharp) Méthode

SetDestination() public méthode

public SetDestination ( System.Vector2 destination ) : void
destination System.Vector2
Résultat void
        public void SetDestination(Vector2 destination)
        {
            destination -= this.position;
            Vector2 direction = destination.Normalized();
            currentLength = Math.Min(maxLength, destination.Length);
            Point2 = direction * currentLength;

            // update the angle between the rope and the up vector (if required)
            if (!angleSet)
            {
                angle = (float)Math.Acos(Vector2.Dot(new Vector2(0, 1), Point2.Normalized()));

                angleSet = true;
            }
        }

Same methods

Rope::SetDestination ( float x, float y ) : void

Usage Example

Exemple #1
0
            public Example()
            {
                window = new Window(800, 600, "Aiv.Fast2D.Example");

                //window.CullBackFaces();

                window.SetLogger(new ExampleLogger());
                window.SetIcon("Aiv.Fast2D.Example.Assets.2.ico");

                window.Position = new Vector2(0, 0);

                //window.SetCursor(false);

                logoAiv = new Texture("Aiv.Fast2D.Example.Assets.LogoAIV.png");


                alien = new Texture("Aiv.Fast2D.Example.Assets.owl.png");


                logo = new Sprite(logoAiv.Width, logoAiv.Height);

                height = 150;

                ship = new Sprite(alien.Width / 10, height);

                ship2 = new Sprite(alien.Width / 10, height);

                square = new Sprite(100, 100);

                tiles = new InstancedSprite(100, 100, 3);
                tiles.SetPosition(0, new Vector2(150, 100));
                tiles.SetPosition(1, new Vector2(200, 200));
                tiles.SetPosition(2, new Vector2(500, 500));

                tiles.SetScale(0, new Vector2(0.5f, 0.5f));
                tiles.SetScale(1, new Vector2(1.5f, 1.5f));

                tiles2 = new InstancedSprite(20, 20, 30);

                screen = new RenderTexture(800, 600);

                fake = new RenderTexture(1, 1);
                fake.Dispose();

                monitor          = new Sprite(100, 100);
                monitor.position = new Vector2(400, 200);

                index = 0;
                t     = 0;

                window.SetClearColor(100, 100, 100);

                counter = 0;

                particleSystem          = new ParticleSystem(2, 2, 100);
                particleSystem.position = new Vector2(400, 200);

                rope          = new Rope(400, 3);
                rope.position = new Vector2(400, 200);
                rope.SetDestination(new Vector2(400, 400));

                ship2.pivot = new Vector2(alien.Width / 20, height / 2);

                particleSystem2 = new ParticleSystem(1, 2, 50);

                triangle   = new Mesh();
                triangle.v = new float[] { 100, 100, 50, 200, 150, 200 };
                triangle.UpdateVertex();
                triangle.uv = new float[] { 0.5f, 0.5f, 0, 0, 1, 0 };
                triangle.UpdateUV();

                farTriangles   = new Mesh();
                farTriangles.v = new float[]
                {
                    300, 100,
                    200, 200,
                    400, 200,

                    400, 400,
                    300, 500,
                    500, 500
                };
                farTriangles.UpdateVertex();

                colouredTriangle   = new Mesh();
                colouredTriangle.v = new float[]
                {
                    500, 200,
                    400, 300,
                    600, 300
                };
                colouredTriangle.UpdateVertex();

                colouredTriangle.vc = new float[]
                {
                    1, 0, 0, 0.5f,
                    0, 1, 0, 0.5f,
                    0, 0, 1, 0.5f
                };
                colouredTriangle.UpdateVertexColor();

                alien2      = new Texture("Aiv.Fast2D.Example.Assets.2.png");
                maskedAlien = new RenderTexture(alien2.Width, alien2.Height);
                spriteMask  = new Sprite(50, 50);

                circleMask  = new Texture("Aiv.Fast2D.Example.Assets.mask_circle.png");
                circleMask2 = new Texture("Aiv.Fast2D.Example.Assets.mask_circle2.png");

                maskedObject          = new Sprite(alien2.Width, alien2.Height);
                maskedObject.position = new Vector2(200, 200);
                maskedBackground      = new Sprite(alien2.Width, alien2.Height);

                mainEffect         = window.AddPostProcessingEffect(new GrayscaleEffect());
                mainEffect.enabled = false;

                window.AddPostProcessingEffect(new MaskEffect("Aiv.Fast2D.Example.Assets.mask_circle.png"));

                window.AddPostProcessingEffect(new BlackBands());

                window.AddPostProcessingEffect(new RedBands());

                // insert a postprocessing effect at the specific position
                window.SetPostProcessingEffect(1, new WASDEffect());

                window.SetPostProcessingEffect(1, new WobbleEffect(5));

                tileMap = new Tilemap("Assets/map001.csv", "Assets/tiles_spritesheet.png");
            }
All Usage Examples Of Aiv.Fast2D.Example.Rope::SetDestination