Game Development Community

T2DPolygon does not respond to flip when Mounted

by Damian Reeves · in Torque X 2D · 03/29/2010 (3:38 pm) · 0 replies

I have been trying to get a T2DPolygon I am using for line of sight to flip (so that its direction can correspond to the Actor's direction) to no avail. I've tried the code below along with setting FlipX after I know the Actor's FlipX has been set, but still it doesn't flip. Any ideas?

private T2DPolygon CreateLineOfSightPolygon() {
            // Make a new poly.  
            var pointVector = T2DVectorUtil.VectorFromAngle(LineOfSightAngle);
            var poly = new T2DPolygon {
                Primitive = 3,
                // Set it's vertices to something simple.
                // Starts at the top left and moves clockwise.
                Vertices = new[] {
                                new Vector2(0, 0),
                                new Vector2(1, pointVector.X), 
                                new Vector2(1, pointVector.Y),
                                new Vector2(0, 0)
                            },
                Size = _lineOfSightVector,
                Position = Vector2.Zero,
                Color = Color.Green.ToVector4(),
                Visible = true
            };
            TorqueObjectDatabase.Instance.Register(poly);
            return poly;
        }

        protected override bool _OnRegister(TorqueObject owner) {
            if (!base._OnRegister(owner) || !(owner is T2DSceneObject))
                return false;

            _lineOfSightPolygon = CreateLineOfSightPolygon();
            _lineOfSightPolygon.InheritMountFlip = true;
            _lineOfSightPolygon.Mount(SceneObject, string.Empty, _lineOfSightMountOffset, _lineOfSightRotationOffset, true);
            _lineOfSightPolygon.InheritMountFlip = true;
            
            return true;
        }

About the author

Recent Threads