Example #1
0
        public void draw()
        {
            float legAngle = (float)Math.Sin(moveValue);

            Vector2 newBody = body * scale;

            MatrixTransformer matrixTransformer = new MatrixTransformer(legAngle, Vector2.Zero, -body);
            Vector2 newRightKnee = matrixTransformer.applyMatrix(rightKnee * scale);
            Vector2 newRightFoot = matrixTransformer.applyMatrix(rightFoot * scale);

            matrixTransformer.setMatrix(-legAngle, Vector2.Zero, -body);
            Vector2 newLeftKnee = matrixTransformer.applyMatrix(leftKnee * scale);
            Vector2 newLeftFoot = matrixTransformer.applyMatrix(leftFoot * scale);

            lineBatch.setMatrix(0, position + level.offset);
            lineBatch.setColor(color);

            lineBatch.drawLine(body, newRightKnee);
            lineBatch.drawLine(newRightKnee, newRightFoot);
            lineBatch.drawLine(body, newLeftKnee);
            lineBatch.drawLine(newLeftKnee, newLeftFoot);
        }