Module: AuthorEngine::TouchHandler
- Included in:
- GameRunner
- Defined in:
- lib/author_engine/game/opal/touch_handler.rb
Defined Under Namespace
Classes: Touch
Instance Method Summary collapse
- #copy_touch(touch) ⇒ Object
- #handle_touch_cancel(event) ⇒ Object
- #handle_touch_end(event) ⇒ Object
- #handle_touch_move(event) ⇒ Object
- #handle_touch_start(event) ⇒ Object
- #set_touch(touch) ⇒ Object
- #touch_handler_setup ⇒ Object
Instance Method Details
#copy_touch(touch) ⇒ Object
8 9 10 |
# File 'lib/author_engine/game/opal/touch_handler.rb', line 8 def copy_touch(touch) Touch.new(`touch.pageX`, `touch.pageY`, `touch.pageX`, `touch.pageY`) end |
#handle_touch_cancel(event) ⇒ Object
51 52 53 |
# File 'lib/author_engine/game/opal/touch_handler.rb', line 51 def handle_touch_cancel(event) handle_touch_end(event) end |
#handle_touch_end(event) ⇒ Object
55 56 57 58 59 60 61 62 63 64 |
# File 'lib/author_engine/game/opal/touch_handler.rb', line 55 def handle_touch_end(event) `#{event}.preventDefault()` touches = `#{event}.changedTouches` `for (var i = 0; i < #{touches}.length; i++) { #{@current_touches.delete(`touches[i].identifier`)} }` return nil end |
#handle_touch_move(event) ⇒ Object
40 41 42 43 44 45 46 47 48 49 |
# File 'lib/author_engine/game/opal/touch_handler.rb', line 40 def handle_touch_move(event) `#{event}.preventDefault()` touches = `#{event}.changedTouches` `for (var i = 0; i < #{touches}.length; i++) { #{set_touch(`touches[i]`)} }` return nil end |
#handle_touch_start(event) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/author_engine/game/opal/touch_handler.rb', line 21 def handle_touch_start(event) `#{event}.preventDefault()` touches = `#{event}.changedTouches` `for (var i = 0; i < #{touches}.length; i++) { #{@current_touches[`touches[i].identifier`] = copy_touch(`touches[i]`)} }` if @fullscreen_button && @fullscreen_button.trigger?(@current_touches) `if (document.fullscreenElement == null && #{@game.}.requestFullscreen) { #{game.}.requestFullscreen() } else if(document.fullscreenElement != null && document.exitFullscreen) { document.exitFullscreen() } ` end return nil end |
#set_touch(touch) ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/author_engine/game/opal/touch_handler.rb', line 12 def set_touch(touch) struct = @current_touches[`#{touch}.identifier`] struct.x = `#{touch}.pageX` struct.y = `#{touch}.pageY` return nil end |
#touch_handler_setup ⇒ Object
4 5 6 |
# File 'lib/author_engine/game/opal/touch_handler.rb', line 4 def touch_handler_setup @current_touches = {} end |