Method: AuthorEngine::TouchJoystick#draw

Defined in:
lib/author_engine/game/opal/touch_joystick.rb

#drawObject



20
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_joystick.rb', line 20

def draw
  #Clear
  combo = @radius + @joystick_radius
  `#{@game.authorengine_canvas_context}.clearRect(#{@x - combo}, #{@y - combo}, #{combo + combo}, #{combo + combo})`

  # Background
  `#{@game.authorengine_canvas_context}.fillStyle = #{@background}`
  `#{@game.authorengine_canvas_context}.beginPath()`
  `#{@game.authorengine_canvas_context}.arc(#{@x}, #{@y}, #{@radius}, 0, 2 * Math.PI)`
  `#{@game.authorengine_canvas_context}.fill()`

  # Joystick
  `#{@game.authorengine_canvas_context}.beginPath()`
  `#{@game.authorengine_canvas_context}.fillStyle = #{@color}`
  `#{@game.authorengine_canvas_context}.arc(#{@joystick_x}, #{@joystick_y}, #{@joystick_radius}, 0, 2 * Math.PI)`
  `#{@game.authorengine_canvas_context}.fill()`

  return nil
end