Пример #1
0
        private static void DrawRotatedCharacter(CanvasCharacterRenderer characterRenderer)
        {
            characterRenderer.CalculateEntityDrawPosition();

            //var TO_RADIANS = JsMath.PI / 180;
            // save the current co-ordinate system
            // before we screw with it
            _canvasRenderingContext2D.save();

            // move to the middle of where we want to draw our image
            _canvasRenderingContext2D.translate(characterRenderer.RenderPosition.X, characterRenderer.RenderPosition.Y);

            // rotate around that point, converting our
            // angle from degrees to radians
            _canvasRenderingContext2D.rotate(characterRenderer.RenderRotation);// * TO_RADIANS);

            // draw it up and to the left by half the width
            // and height of the image
            // _canvasRenderingContext2D.drawImage(_playerImage, -(image.width / 2), -(image.height / 2));
            _canvasRenderingContext2D.drawImage(_playerImage, characterRenderer.RenderPosition.X,
                characterRenderer.RenderPosition.Y, characterRenderer.RenderPosition.Width, characterRenderer.RenderPosition.Height);

            // and restore the co-ords to how they were when we began
            _canvasRenderingContext2D.restore();
        }
Пример #2
0
        private static void DrawCharacter(CanvasCharacterRenderer characterRenderer)
        {
            characterRenderer.CalculateEntityDrawPosition();

            _canvasRenderingContext2D.drawImage(_playerImage, characterRenderer.RenderPosition.X,
                characterRenderer.RenderPosition.Y,characterRenderer.RenderPosition.Width, characterRenderer.RenderPosition.Height);
        }