Class: AuthorEngine::View

Inherits:
Object
  • Object
show all
Includes:
Part::Colors, Support
Defined in:
lib/author_engine/view.rb

Direct Known Subclasses

CodeEditor, LevelEditor, PlayViewer, SpriteEditor

Constant Summary

Constants included from Part::Colors

Part::Colors::COLORS

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Part::Colors

#black, #blue, #brown, #dark_blue, #dark_gray, #dark_green, #dark_purple, #green, #indigo, #light_gray, #orange, #peach, #pink, #red, #rgb, #white, #xml_color, #yellow

Methods included from Support

#code_editor, #mouse_over?, #sprite_editor, #window

Constructor Details

#initialize(x:, y:, width:, height:, background: Gosu::Color::BLACK) ⇒ View

Returns a new instance of View.



15
16
17
18
19
20
21
22
23
# File 'lib/author_engine/view.rb', line 15

def initialize(x:, y:, width:, height:, background: Gosu::Color::BLACK)
  @x, @y, @width, @height, @background = x, y, width, height, background

  @x_padding = Button::PADDING * window.scale_x
  @y_padding = Button::PADDING * window.scale_y

  self.class.instance = self
  setup
end

Instance Attribute Details

#backgroundObject (readonly)

Returns the value of attribute background.



14
15
16
# File 'lib/author_engine/view.rb', line 14

def background
  @background
end

#heightObject (readonly)

Returns the value of attribute height.



14
15
16
# File 'lib/author_engine/view.rb', line 14

def height
  @height
end

#widthObject (readonly)

Returns the value of attribute width.



14
15
16
# File 'lib/author_engine/view.rb', line 14

def width
  @width
end

#xObject (readonly)

Returns the value of attribute x.



14
15
16
# File 'lib/author_engine/view.rb', line 14

def x
  @x
end

#yObject (readonly)

Returns the value of attribute y.



14
15
16
# File 'lib/author_engine/view.rb', line 14

def y
  @y
end

Class Method Details

.instanceObject



6
7
8
# File 'lib/author_engine/view.rb', line 6

def self.instance
  @instance
end

.instance=(klass) ⇒ Object



10
11
12
# File 'lib/author_engine/view.rb', line 10

def self.instance=(klass)
  @instance = klass
end

Instance Method Details

#blurObject



31
32
# File 'lib/author_engine/view.rb', line 31

def blur
end

#button_down(id) ⇒ Object



49
50
# File 'lib/author_engine/view.rb', line 49

def button_down(id)
end

#button_up(id) ⇒ Object



52
53
# File 'lib/author_engine/view.rb', line 52

def button_up(id)
end

#drawObject



34
35
36
# File 'lib/author_engine/view.rb', line 34

def draw
  Gosu.draw_rect(@x, @y, @width, @height, @background)
end

#focusObject



28
29
# File 'lib/author_engine/view.rb', line 28

def focus
end

#mouse_inside_view?Boolean

Returns:

  • (Boolean)


38
39
40
41
42
43
44
# File 'lib/author_engine/view.rb', line 38

def mouse_inside_view?
  if window.mouse_x.between?(@x, @x+@width)
    if window.mouse_y.between?(@y, @y+@height)
      return true
    end
  end
end

#setupObject



25
26
# File 'lib/author_engine/view.rb', line 25

def setup
end

#updateObject



46
47
# File 'lib/author_engine/view.rb', line 46

def update
end