如何使用javascript在smartface、io IDE中旋转此图像?

如何使用javascript在smartface、io IDE中旋转此图像?,javascript,user-interface,smartface.io,Javascript,User Interface,Smartface.io,我需要这个图像,在按下按钮时,向左旋转90度,在另一个按钮上向右旋转90度。这是我的密码。任何帮助都将不胜感激 var pinWheel = new SMF.UI.Image({ name :"Pin Wheel", image : "assets://pin_wheel.png", positionBackgroundImage : "CENTER", top : "60%", imageFillType: SMF.UI.ImageFillType.AS

我需要这个图像,在按下按钮时,向左旋转90度,在另一个按钮上向右旋转90度。这是我的密码。任何帮助都将不胜感激

var pinWheel = new SMF.UI.Image({
    name :"Pin Wheel",
    image : "assets://pin_wheel.png",
    positionBackgroundImage : "CENTER",
    top : "60%",
    imageFillType: SMF.UI.ImageFillType.ASPECTFIT
});
具有图像处理的静态功能。函数将帮助您解决问题

以下是您的示例代码:

var img = new SMF.UI.Image({
  name: "img",
  image: "smartface.png",
  left: "15%",
  top: "20%",
  width: "70%",
  height: "10%",
  imageFillType: SMF.UI.ImageFillType.ASPECTFIT
});

var btn = new SMF.UI.TextButton({
  name: "btn",
  text: "Rotate!",
  onPressed: function() {
    var myImageUri = "smartface.png";
    var im = new SMF.Bitmap({
      imageUri: myImageUri,
      onSuccess: function(e) {
        im.rotate({
          angle: 90,
          format: SMF.ImageFormat.PNG,
          compressionRate: 0.7,
          onSuccess: function(e) {
            img.image = e.image;
          },
          onError: function(e) {
            alert("Error: " + e.message);
          }
        });
      },
      onError: function(e) {
        alert("Error: " + e.message);
      }
    });
  },
  left: "15%",
  top: "70%",
  width: "70%",
  height: "10%"
});

所以这是可行的,这绝对是令人惊讶的,但似乎有某种滞后或过渡,我想消除。我非常感谢到目前为止所有的帮助,但是你知道我如何才能做到这一点吗?@Binary111 SMF.Bitmap函数是异步工作的,很可能这对你来说是滞后的,我认为你对此无能为力。您可以显示活动指示器(如果旋转需要那么多时间)以获得更好的用户体验。哦,好的,谢谢您的帮助!这是一个游戏,所以我需要快速响应,但我想我可以添加一个以前旋转过的新图像,并删除下面的图像。