• <small id='Q9072'></small><noframes id='Q9072'>

      • <bdo id='Q9072'></bdo><ul id='Q9072'></ul>
      <tfoot id='Q9072'></tfoot>

      1. <i id='Q9072'><tr id='Q9072'><dt id='Q9072'><q id='Q9072'><span id='Q9072'><b id='Q9072'><form id='Q9072'><ins id='Q9072'></ins><ul id='Q9072'></ul><sub id='Q9072'></sub></form><legend id='Q9072'></legend><bdo id='Q9072'><pre id='Q9072'><center id='Q9072'></center></pre></bdo></b><th id='Q9072'></th></span></q></dt></tr></i><div id='Q9072'><tfoot id='Q9072'></tfoot><dl id='Q9072'><fieldset id='Q9072'></fieldset></dl></div>

        <legend id='Q9072'><style id='Q9072'><dir id='Q9072'><q id='Q9072'></q></dir></style></legend>
      2. 如何在画布中旋转一张图像?

        时间:2023-10-13

        <small id='WOk56'></small><noframes id='WOk56'>

          <bdo id='WOk56'></bdo><ul id='WOk56'></ul>

            <i id='WOk56'><tr id='WOk56'><dt id='WOk56'><q id='WOk56'><span id='WOk56'><b id='WOk56'><form id='WOk56'><ins id='WOk56'></ins><ul id='WOk56'></ul><sub id='WOk56'></sub></form><legend id='WOk56'></legend><bdo id='WOk56'><pre id='WOk56'><center id='WOk56'></center></pre></bdo></b><th id='WOk56'></th></span></q></dt></tr></i><div id='WOk56'><tfoot id='WOk56'></tfoot><dl id='WOk56'><fieldset id='WOk56'></fieldset></dl></div>
          1. <tfoot id='WOk56'></tfoot>

                  <legend id='WOk56'><style id='WOk56'><dir id='WOk56'><q id='WOk56'></q></dir></style></legend>
                    <tbody id='WOk56'></tbody>

                  本文介绍了如何在画布中旋转一张图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我正在制作一个 HTML5 画布游戏,我希望旋转其中一张图片.

                  I am making an HTML5 canvas game, and I wish to rotate one of the images.

                  var link = new Image();
                  link.src='img/link.png';
                  link.onload=function(){
                      ctx.drawImage(link,x,y,20,20); // draws a chain link or dagger
                  }
                  

                  我想旋转这张图片.旋转图像的标准方法是在画布上下文对象上设置旋转.但是,这会旋转整个游戏!我不想这样做,只想旋转这个精灵.我该怎么做?

                  I wish to rotate this image. The standard way of rotating image was to set a rotation on the canvas context object. However, that rotates the entire game! I don't want to do that, and only wish to rotate this one sprite. How do I do that?

                  推荐答案

                  使用 .save().restore() (更多信息):

                  link.onload=function(){
                      ctx.save(); // save current state
                      ctx.rotate(Math.PI); // rotate
                      ctx.drawImage(link,x,y,20,20); // draws a chain link or dagger
                      ctx.restore(); // restore original states (no rotation etc)
                  }
                  

                  这篇关于如何在画布中旋转一张图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:jQuery:在点击功能上切换旋转 div 下一篇:React Native:如何为图像的旋转设置动画?

                  相关文章

                  最新文章

                • <legend id='qzKYz'><style id='qzKYz'><dir id='qzKYz'><q id='qzKYz'></q></dir></style></legend>

                  <tfoot id='qzKYz'></tfoot>
                  <i id='qzKYz'><tr id='qzKYz'><dt id='qzKYz'><q id='qzKYz'><span id='qzKYz'><b id='qzKYz'><form id='qzKYz'><ins id='qzKYz'></ins><ul id='qzKYz'></ul><sub id='qzKYz'></sub></form><legend id='qzKYz'></legend><bdo id='qzKYz'><pre id='qzKYz'><center id='qzKYz'></center></pre></bdo></b><th id='qzKYz'></th></span></q></dt></tr></i><div id='qzKYz'><tfoot id='qzKYz'></tfoot><dl id='qzKYz'><fieldset id='qzKYz'></fieldset></dl></div>

                  <small id='qzKYz'></small><noframes id='qzKYz'>

                        <bdo id='qzKYz'></bdo><ul id='qzKYz'></ul>