blob: 2c690eb2b9071f97203a8f0020ab3ba074fd64d7 (
plain)
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
62
63
|
<!DOCTYPE html>
<html id="body">
<head>
<title>Detailed Comparison</title>
<script type="text/javascript" src ="scripts/jquery-3.2.1.js"></script>
<script type="text/javascript" src ="scripts/jquery.animateSprite.js"></script>
<script type="text/javascript" src ="scripts/top.js" ></script>
<link rel="stylesheet" type="text/css" href="styles/top.css">
</head>
<p id="demo"></p>
<div id="animation" class="animation"></div><br>
<button id="set_dim"onclick="set_dim()">SetDim</button>
<button id="start">Start</button>
<button id="play">Play</button>
<button id="stop">Stop</button>
<button id="changeFPS">Change FPS</button><br>
<script>
/* global $ */
var currentFps = 1;
var animationSettings = {
fps: currentFps,
loop: true,
autoplay: false,
animations: {
walkRight: [0, 3]
}
};
$(document).ready(function(){
$("#start").click(function(){
$('.animation').animateSprite(animationSettings);
var play = function(){
$('.animation').animateSprite('play');
}
$('#play').on('click', play);
$('#stop').on('click', function(){
$('.animation').animateSprite('stop');
});
$('#changeFPS').on('click', function(){
currentFps = (currentFps === 2) ? 1 : 2;
$('.animation').animateSprite('fps', currentFps);
});
$('body').on('keydown', function(ev){
if (ev.keyCode === 39){
goRight();
} else if (ev.keyCode === 37) {
goLeft();
}
console.log('ev', ev.keyCode);
});
});
});
</script>
</body>
</html>
|