0
我正試圖在array
中存儲圖像的'y'
座標,並通過點擊進行循環。Javascript應用y座標onclick。
我已經存儲的座標在array
和event listener
乖乖地改變
我的形象的y
協調,但使用array index
而不是給定的值。
例如0,1,2,3
,而不是50 -50 -150 -250
posa = 50;
posb = -50;
posc = -150;
posd = -250;
position = [posa, posb, posc, posd];
index = 0;
clue1.addEventListener("click", function(event) {
//clue1.y = posb; //works
clue1.y = (index++)%(position.length);
//alert(position); //returns 50 -50 -150 -250
//alert(clue1.y): //returns 0 1 2 3 (the y position of my image)
stage.update();
});
非常感謝那些誰看一看
你是個天才!那是'完美的,你剛剛結束了四天的痛苦!謝謝@ skstar。 – Harry