1
我是新搭建Metro應用程序。 我只是想創建每秒一個新的矩形,並開始與位置x = 0Win8 Metro應用程序setInterval Javascript
但與我的代碼,似乎在繪製第一個矩形之前調用x + = 10。但我不知道我怎麼能改變這個..有人可以幫我嗎?
(function() {
"use strict";
var app = WinJS.Application;
var activation = Windows.ApplicationModel.Activation;
WinJS.strictProcessing();
var x = 0;
var y = 0;
function Clock(context) {
context.fillRect(x, y, 9, 9);
context.fillStyle = "red";
x += 10;
}
app.onactivated = function (args) {
if (args.detail.kind === activation.ActivationKind.launch) {
if (args.detail.previousExecutionState !== activation.ApplicationExecutionState.terminated) {
var canvas = document.getElementById("uhr");
var context = canvas.getContext("2d");
setInterval(function() { Clock(context) }, 1000);
} else {
}
args.setPromise(WinJS.UI.processAll());
}
};
app.oncheckpoint = function (args) {
};
app.start();
})();