1
1
import 'hackforplay/enchantjs-kit' ;
2
-
2
+ import TextArea from 'hackforplay/ui/textarea' ;
3
3
4
4
function refocus ( ) {
5
5
window . document . activeElement . blur ( ) ; // Blur an enchantBook
@@ -33,6 +33,7 @@ Hack.fun2str = function(func) {
33
33
return '' ;
34
34
} ;
35
35
36
+ // 【旧ログ機能】
36
37
// textarea : 画面全体をおおう半透明のテキストエリア(DOM)
37
38
Hack . textarea = ( function ( ) {
38
39
// scope: new Entity
@@ -78,6 +79,18 @@ Hack.textarea = (function() {
78
79
79
80
} ) . call ( new enchant . Entity ( ) ) ;
80
81
82
+ // canvas のテキストエリアを生成
83
+ const textArea = new TextArea ( 380 , 60 ) ;
84
+ textArea . moveTo ( 60 , 5 ) ;
85
+ textArea . verticalNormalizedPosition = 1 ;
86
+ textArea . autoResizeVertical = true ;
87
+ textArea . maxHeight = 310 ;
88
+ Hack . textArea = textArea ;
89
+ game . on ( 'awake' , ( ) => {
90
+ Hack . menuGroup . addChild ( textArea ) ;
91
+ } ) ;
92
+
93
+ // 画面に文字を表示する(次の行に追加)
81
94
Hack . log = function ( ) {
82
95
try {
83
96
var values = [ ] ;
@@ -91,16 +104,24 @@ Hack.log = function() {
91
104
break ;
92
105
}
93
106
}
94
- this . textarea . text = values . join ( ' ' ) + ( this . textarea . text !== '' ? '\n' : '' ) + this . textarea . text ;
95
- this . textarea . show ( ) ;
96
107
108
+ this . textArea . push ( values . join ( ' ' ) + ( this . textarea . text !== '' ? '\n' : '' ) + this . textarea . text ) ;
109
+ this . textArea . show ( ) ;
97
110
} catch ( e ) {
98
111
Hack . log ( 'Error' , e . message ) ;
99
112
}
100
113
} ;
101
114
115
+ // 画面に文字を表示する(上書き)
116
+ Hack . show = function ( ) {
117
+ Hack . textArea . clear ( ) ;
118
+ Hack . log . apply ( this , arguments ) ;
119
+ } ;
120
+
102
121
Hack . clearLog = function ( ) {
103
- this . textarea . text = '' ;
122
+ Hack . textarea . text = '' ;
123
+ Hack . textArea . clear ( ) ;
124
+ Hack . textArea . hide ( ) ;
104
125
} ;
105
126
106
127
// enchantBook
@@ -574,4 +595,4 @@ game.addEventListener('load', function() {
574
595
}
575
596
throw new Error ( 'Hack.css2rgb requires CSS style string or Array of number' ) ;
576
597
} ;
577
- } ) ( ) ;
598
+ } ) ( ) ;
0 commit comments