如何将位图图像的注册点设置为底部中心?
How to set the registration point of a Bitmap image to the bottom centre?
我正在尝试将图像的注册点设置为底部中心,以便它可以围绕该点旋转。到目前为止,我的代码如下所示:
var img = new createjs.Bitmap("img.png");
img.x = 200;
img.y = 180;
img.scaleX = 0.35;
img.scaleY = 0.35;
img.regX = img.width/2;
img.regY = 0;
img.rotation = 15;
canvas.addChild(img);
我试过更改 img.regY 的数字,但我似乎无法正确设置。
什么是 redBalloon.width
?
最好的方法是等到图像加载完毕,然后使用其自然宽度。
img.image.onload = function() {
img.regX = img.image.naturalWidth;
img.regY = img.image.naturalHeight;
}
希望对您有所帮助。
我正在尝试将图像的注册点设置为底部中心,以便它可以围绕该点旋转。到目前为止,我的代码如下所示:
var img = new createjs.Bitmap("img.png");
img.x = 200;
img.y = 180;
img.scaleX = 0.35;
img.scaleY = 0.35;
img.regX = img.width/2;
img.regY = 0;
img.rotation = 15;
canvas.addChild(img);
我试过更改 img.regY 的数字,但我似乎无法正确设置。
什么是 redBalloon.width
?
最好的方法是等到图像加载完毕,然后使用其自然宽度。
img.image.onload = function() {
img.regX = img.image.naturalWidth;
img.regY = img.image.naturalHeight;
}
希望对您有所帮助。