Class: Rubygame::Events::WindowResized

Inherits:
Object
  • Object
show all
Defined in:
lib/rubygame/events/misc_events.rb

Overview

WindowResized is an event that occurs when the Rubygame application window is resized by the user. This can only happen if the Screen mode was set with the “resizable” flag.

Your application should respond to this event by setting the Screen mode again with the new #size and redrawing.

If you ignore this event, the “active” area of the Screen will stay the same size, and the rest (if the window was enlarged) will be black and won’t receive any changes (blits, drawing, etc.).

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(size) ⇒ WindowResized

Returns a new instance of WindowResized.



124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# File 'lib/rubygame/events/misc_events.rb', line 124

def initialize( size )

  @size = size.to_ary.dup
  @size.freeze

  unless @size.length == 2
    raise ArgumentError, "size must have exactly 2 parts (got %s)"%@size.length
  end

  @size.each do |part|
    if part <= 0
      raise ArgumentError, "size must be positive (got %s)"%part
    end
  end

end

Instance Attribute Details

#sizeObject (readonly)

Returns the value of attribute size.



122
123
124
# File 'lib/rubygame/events/misc_events.rb', line 122

def size
  @size
end