module AuthorEngine::TouchHandler
Constants
- Touch
Public Instance Methods
copy_touch(touch)
click to toggle source
# 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)
click to toggle source
# 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)
click to toggle source
# 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)
click to toggle source
# 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)
click to toggle source
# 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.authorengine_canvas}.requestFullscreen) { #{game.authorengine_canvas}.requestFullscreen() } else if(document.fullscreenElement != null && document.exitFullscreen) { document.exitFullscreen() } ` end return nil end
set_touch(touch)
click to toggle source
# 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()
click to toggle source
# File lib/author_engine/game/opal/touch_handler.rb, line 4 def touch_handler_setup @current_touches = {} end