RGSS1的Window类试写
很多人都试写过Window类,不过很多地方没考虑到F1中说Window类内部由大量精灵构成,所以试写如下,不过经过本人"鉴定",
Window类内部由大量精灵构成是错的,因为这样太耗内存了...
好像有bug...#==============================================================================# ■ Window#------------------------------------------------------------------------------# 游戏中全部窗口的超级类。 伪.源代码#==============================================================================class Window#--------------------------------------------------------------------------# ● 定义实例变量#--------------------------------------------------------------------------attr_reader :stretchattr_reader :windowskinattr_reader :widthattr_reader :heightattr_reader :contentsattr_reader :activeattr_reader :pauseattr_reader :visible attr_reader :opacityattr_reader :back_opacity attr_reader :contents_opacityattr_reader :cursor_rectattr_reader :xattr_reader :yattr_reader :oxattr_reader :oyattr_reader :z#--------------------------------------------------------------------------# ● 初始化对像#--------------------------------------------------------------------------def initialize(viewport=Viewport.new(0,0,640,480)) @disposed = false @width = 64 @height = 64 @x = 0 @y = 0 @ox = 0 @oy = 0 @z = 0 @viewport1= viewport @_frame = Sprite.new(@viewport1) @_back = Sprite.new(@viewport1) @_cursor = Sprite.new(@viewport1) @_pause = Sprite.new(@viewport1) @viewport2= Viewport.new(self.x+16,self.y+16,self.width-32,self.height-32) @_content = Sprite.new(@viewport2) @cursor_rect= Rect.new(0,0,0,0) @active = true self.stretch= true @pause = false @up_bitmap= Bitmap.new(16,16) @dn_bitmap= Bitmap.new(16,16) @lt_bitmap= Bitmap.new(16,16) @rt_bitmap= Bitmap.new(16,16) @_up = Sprite.new(@viewport1) @_dn = Sprite.new(@viewport1) @_lt = Sprite.new(@viewport1) @_rt = Sprite.new(@viewport1) @_up.bitmap = @up_bitmap @_dn.bitmap = @dn_bitmap @_lt.bitmap = @lt_bitmap @_rt.bitmap = @rt_bitmap @_up.visible= @_dn.visible = @_lt.visible = @_rt.visible = false @_up.ox = @_dn.ox = @_lt.ox = @_rt.ox = 8 @_up.oy = @_dn.oy = @_lt.oy = @_rt.oy = 8 @opacity = 255 @back_opacity = 255 @contents_opacity = 255 # @cursor_bitmap = Bitmap.new(32,32) @pause_bitmap= (0..3).inject([]){|a,i|a rect.widthend#--------------------------------------------------------------------------# ● 壁纸显示方法#--------------------------------------------------------------------------def stretch=(stretch) if @disposed raise(RGSSError,"disposed window") else @stretch = stretch show_back endend#--------------------------------------------------------------------------# ● 壁纸显示方法 更换# 为了严谨,窗口周围缩小了 2 像素大小。这是为了能自然地看见圆角形窗口。#--------------------------------------------------------------------------def show_back skin_explain return if self.height
页:
[1]