-
Notifications
You must be signed in to change notification settings - Fork 2
/
08 - Hide mouse.html
61 lines (44 loc) · 1.32 KB
/
08 - Hide mouse.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<!doctype html>
<html lang="en">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta charset="utf-8" />
<meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1">
<title>initMouse</title>
<!-- EasySprite -->
<script src="EasySprite.js"></script>
<!-- Center rendergame -->
<style>
#game { display: block; margin: 0 auto;}
</style>
</head>
<body>
<canvas id='game'></canvas>
<script>
var countClic = 0;
openScreen("game", 0, 0, 800, 600);
// Init mouse : option true hide mouse.
initMouse(true);
var ball = loadSprite("assets/image/ball.png", onLoadSuccess)
function onLoadSuccess() {
anchorSprite(ball, 0.5, 0.5);
renderGame()
}
function renderGame() {
var x = mouseX();
var y = mouseY();
clearScreen("green");
if (x + y >=0) {
displaySprite(ball, x, y)
} else {
displaySprite(ball, ball.x, ball.y);
}
displayText("x/y " + x + " / " + y, 40, 40, "Arial", 25, "white");
displayText("mouseState() " + mouseState(), 40, 80, "Arial", 25, "white");
displayText("Count Clicks " + countClic, 40, 120, "Arial", 25, "white");
if (mouseButton() == true) {countClic ++};
requestAnimationFrame(renderGame);
}
</script>
</body>
</html>