Class: GGLib::FadeScreen

Inherits:
StateObject show all
Defined in:
lib/state.rb

Defined Under Namespace

Classes: FadeIn

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from StateObject

#button_down, #button_up, #end, #onEnd, #onTerminate, #start, #update, #window

Constructor Details

#initialize(fadeTo = nil, speed = 1) ⇒ FadeScreen

Returns a new instance of FadeScreen.



69
70
71
72
73
74
75
76
# File 'lib/state.rb', line 69

def initialize(fadeTo=nil, speed=1)
  $faded=false
  @image=Gosu::Image.new($window, $gglroot+"/media/black.bmp", true)
  @fading=false
  @speed=speed
  @fadeTo=fadeTo
  @color=Gosu::Color.new(0xffffffff)
end

Instance Attribute Details

#widgetIDObject (readonly)

Returns the value of attribute widgetID.



68
69
70
# File 'lib/state.rb', line 68

def widgetID
  @widgetID
end

Instance Method Details

#drawObject



84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/state.rb', line 84

def draw
  if @fading
    @alpha+=@speed
    if @alpha > 255
      @alpha=255
    end
    @color.alpha=@alpha
    @image.draw(0, 0, ZOrder::Top+1, 640, 480, @color)
    if @alpha == 255
      endFade
      @widgetID = FadeIn.new(@speed)
    end
  end
end

#endFadeObject



98
99
100
101
102
103
# File 'lib/state.rb', line 98

def endFade
  @fading=false
  @image=nil
  self.end
  @fadeTo.start if @fadeTo!=nil
end

#fading?Boolean

Returns:

  • (Boolean)


77
78
79
# File 'lib/state.rb', line 77

def fading?
  return @fading
end

#onStartObject



80
81
82
83
# File 'lib/state.rb', line 80

def onStart
  @fading=true
  @alpha=0
end