コード例 #1
0
        public TriangleWall(float x, float y)
        {
            Texture2D texture = GameManager.gameScene.content.Load <Texture2D>("triangleWall");
            var       sprite  = addComponent(new Sprite(texture));


            transform.position = new Vector2(x, y);

            Vector2 v1 = new Vector2(-texture.Width / 2, texture.Height / 2);
            Vector2 v2 = new Vector2(0, -texture.Height / 2);
            Vector2 v3 = new Vector2(texture.Width / 2, texture.Height / 2);

            Vector2[] vertices = new Vector2[] { v1, v2, v3 };


            PolygonCollider collider = new PolygonCollider(vertices);

            addComponent(collider);
            collider.setShouldColliderScaleAndRotateWithTransform(true);

            collider.physicsLayer = (int)Layers.wall;
        }