====== 008 タッチイベント ====== {{:wiki:enchant.js:tips:enchantjs_008_000.png?200|}} ===== 概要 ===== タッチイベントを検知します。ログの出力確認にはChromeを使用しています。 ==== ソースコード ==== // main.js enchant(); window.onload = preloadAssets; var game; var scene; function preloadAssets() { game = new Game(320,480); game.onload = init; game.start(); } function init() { game.scale = 1; game.fps = 30; scene = new Scene(); scene.backgroundColor = "#000"; game.pushScene(scene); main(); } function main() { // タッチイベントを登録。 scene.addEventListener(Event.TOUCH_START,touchStart); scene.addEventListener(Event.TOUCH_MOVE,touchMove); scene.addEventListener(Event.TOUCH_END,touchEnd); } // タッチ開始. function touchStart(e) { console.log(e.type); } // タッチ中. function touchMove(e) { console.log(e.type); } // タッチ終了. function touchEnd(e) { console.log(e.type); } console.log() でログが出力出来ます。仮対応やデバッグ用に重宝します。 ==== ダウンロード ==== {{:wiki:enchant.js:tips:enchantjs_touch_event.zip|}}