File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ <!DOCTYPE html>
2+ < html >
3+ < head >
4+ < meta charset ="utf-8 ">
5+ < link rel ="stylesheet " href ="css/base.css ">
6+ < script src ="https://code.createjs.com/createjs-2015.11.26.min.js "> </ script >
7+ < script >
8+ window . addEventListener ( "load" , init ) ;
9+ function init ( ) {
10+ // Stageオブジェクトを作成。表示リストのルートになります。
11+ var stage = new createjs . Stage ( "myCanvas" ) ;
12+
13+ // Text インスタンスを作成
14+ var label = new createjs . Text ( "" , "80px sans-serif" , "red" ) ;
15+ // Text インスタンスは一度だけしか stage に追加しない
16+ stage . addChild ( label ) ;
17+
18+ // 時間経過のイベント
19+ createjs . Ticker . addEventListener ( "tick" , handleTick ) ;
20+ function handleTick ( ) {
21+ // 現在時間を取得
22+ var now = new Date ( ) ;
23+
24+ // 時間の数値を取得
25+ var h = now . getHours ( ) ; // 時(0〜23)
26+ var m = now . getMinutes ( ) ; // 分(0〜59)
27+ var s = now . getSeconds ( ) ; // 秒(0〜59)
28+
29+ // 表示文言を作成
30+ var time = h + ":" + m + ":" + s ;
31+ // Text インスタンスの文字列を更新
32+ label . text = time ;
33+
34+ // Stageの描画を更新
35+ stage . update ( ) ;
36+ }
37+ }
38+ </ script >
39+ </ head >
40+ < body >
41+ < canvas id ="myCanvas " width ="960 " height ="540 "> </ canvas >
42+ </ body >
43+ </ html >
You can’t perform that action at this time.
0 commit comments