林試圖讓這兩個PNG圖像只需旋轉在我的畫布。圖像比畫布大,因爲我只想顯示輪子旋轉到畫布上的某些部分。我在畫布上獲得了完美的png,它們是圓形的,並與底部對齊並居中,以便它僅顯示輪子的這一部分。我在我的代碼中使用createl和easl和補間。出於某種原因,當我旋轉我的圖像時,它從一些隨機註冊點開始。有沒有一種方法可以讓這張圖片圍繞自己的中心進行旋轉,這個中心位於畫布區域之外?紡車與HTML 5帆布
var CANVAS;
var STAGE;
var CTX;
var imageCount = 0;
var img1Obj = new Image();
var img2Obj = new Image();
var img3Obj = new Image();
var img1;
var img2;
var img3;
var box;
function init(){
CANVAS = document.getElementById("spinWheel");
STAGE = new createjs.Stage(CANVAS);
CTX = CANVAS.getContext('2d');
img1Obj.src = "img/iphone_wheel_outer.png";
img2Obj.src = "img/iphone_wheel_middle.png";
img3Obj.src = "img/iphone_wheel_inner.png";
img1Obj.name = "img1";
img2Obj.name = "img2";
img3Obj.name = "img3";
img1Obj.onload = loadImages;
img2Obj.onload = loadImages;
img3Obj.onload = loadImages;
createjs.Ticker.setFPS(30);
createjs.Ticker.addListener(STAGE);
}
function loadImages(e)
{
if(e.target.name == 'img1'){img1 = new createjs.Bitmap(img1Obj); }
if(e.target.name == 'img2'){img2 = new createjs.Bitmap(img2Obj); }
if(e.target.name == 'img3'){img3 = new createjs.Bitmap(img3Obj); }
imageCount++;
/* Display graphics until all of them are loaded */
if(imageCount == 3)
{
buildInterface();
}
}
function buildInterface(){
img1.x = -370;
img2.x = -370;
img3.x = -370;
img1.y = 235;
img2.y = 235;
img3.y = 235;
createjs.Tween.get(img1,{loop:true})
.to({rotation : 360}, 2000);
STAGE.addChild(img1, img2, img3, box);
}
$(document).ready(function() {
init();
});
請向我們顯示您的代碼。 – KatieK