赞 | 1 |
VIP | 68 |
好人卡 | 15 |
积分 | 4 |
经验 | 16522 |
最后登录 | 2014-7-3 |
在线时间 | 142 小时 |
Lv2.观梦者
- 梦石
- 0
- 星屑
- 375
- 在线时间
- 142 小时
- 注册时间
- 2008-11-20
- 帖子
- 231
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
本帖最后由 癫狂侠客 于 2011-9-10 11:30 编辑
说明: Plane类代码为某侠个人试写的,能支持扩展分辨率,可以让800*600的双远景图的系统成为可能,但是仅某侠单个人测试,可能存在Bug,此代码经优化后可能会整合入DKRM,如有Bug请回复此帖说明,或者给某侠留言,
另外说明,此脚本直接插入后会无效果,只有扩展分辨率采用的着,应该和某侠正是试写的Tileset类一起使用就成了扩展分辨率的真脚本了!
以下是官方解释:
Plane类
平面的类。所谓平面,是在整个画面中排列显示位图图形的特殊的精灵,用来显示全景和雾。
某侠的Plane类伪代码:- #============================================================================
- # ■ Plane
- #----------------------------------------------------------------------------
- # 处理平面的类(某侠编辑伪代码)
- #============================================================================
- class Plane
- #--------------------------------------------------------------------------
- # ● 初始化定义
- #--------------------------------------------------------------------------
- def initialize(v = Viewport.new(0, 0, 640, 480))
- @x = 0
- @y = 0
- @z = 0
- @ox = 0
- @oy = 0
- @ox2 = 0
- @oy2 = 0
- @rect = v.rect
- @zoom_x = 1.0
- @zoom_y = 1.0
- @bitmap = nil
- @contents = Sprite.new
- @n_w = 1
- @n_h = 1
- @visible = true
- @tone = Tone.new(0, 0, 0, 0)
- @color = Color.new(255,255,255,0)
- @blend_type = 0
- @opacity = 255
- @dispose = false
- end
- #--------------------------------------------------------------------------
- # ● 刷新
- #--------------------------------------------------------------------------
- def update
- @contents.x = @x
- @contents.y = @y
- @contents.ox = @ox2
- @contents.oy = @oy2
- @contents.opacity = @opacity
- @contents.visible = @visible
- @contents.tone = @tone
- @contents.blend_type = @blend_type
- @contents.z = @z
- end
- #--------------------------------------------------------------------------
- # ● 装载图形(bitmap)
- #--------------------------------------------------------------------------
- def bitmap=(bitmap)
- if @disposed
- raise(RGSSError,"disposed window")
- else
- @bitmap = bitmap
- count_wh
- update
- end
- end
- #--------------------------------------------------------------------------
- # ● 图形
- #--------------------------------------------------------------------------
- def bitmap
- return if @bitmap != nil
- end
- #--------------------------------------------------------------------------
- # ● X 坐标(x)
- #--------------------------------------------------------------------------
- def x=(x)
- if @disposed
- raise(RGSSError,"disposed window")
- else
- @x = x
- update
- end
- end
- def x
- return @x
- end
- #--------------------------------------------------------------------------
- # ● Y 坐标(y)
- #--------------------------------------------------------------------------
- def y=(y)
- if @disposed
- raise(RGSSError,"disposed window")
- else
- @y = y
- update
- end
- end
- def y
- return @y
- end
- #--------------------------------------------------------------------------
- # ● Z 坐标(z)
- #--------------------------------------------------------------------------
- def z=(z)
- if @disposed
- raise(RGSSError,"disposed window")
- else
- @z = z
- update
- end
- end
- def z
- return @z
- end
- #--------------------------------------------------------------------------
- # ● X 漂移量(ox)
- #--------------------------------------------------------------------------
- def ox=(ox)
- if @disposed
- raise(RGSSError,"disposed window")
- else
- @ox = ox
- @ox2 = ox % (@bitmap.width * @zoom_x).to_i
- update
- end
- end
- def ox
- return @ox
- end
- #--------------------------------------------------------------------------
- # ● Y 漂移量(oy)
- #--------------------------------------------------------------------------
- def oy=(oy)
- if @disposed
- raise(RGSSError,"disposed window")
- else
- @oy = oy
- @oy2 = oy % (@bitmap.height * @zoom_y).to_i
- update
- end
- end
- def oy
- return @oy
- end
- #--------------------------------------------------------------------------
- # ● X 方向缩放(zoom_x)
- #--------------------------------------------------------------------------
- def zoom_x=(zx)
- if @disposed
- raise(RGSSError,"disposed window")
- else
- if @zoom_x != zx
- @zoom_x = zx
- count_wh
- end
- update
- end
- end
- def zoom_x
- return @zoom_x
- end
- #--------------------------------------------------------------------------
- # ● Y 方向缩放(zoom_y)
- #--------------------------------------------------------------------------
- def zoom_y=(zy)
- if @disposed
- raise(RGSSError,"disposed window")
- else
- if @zoom_y != zy
- @zoom_y = zy
- count_wh
- end
- update
- end
- end
- def zoom_y
- return @zoom_y
- end
- #--------------------------------------------------------------------------
- # ● 不透明度(opacity)
- #--------------------------------------------------------------------------
- def opacity=(op)
- if @disposed
- raise(RGSSError,"disposed window")
- else
- @opacity = op
- update
- end
- end
- def opacity
- return @opacity
- end
- #--------------------------------------------------------------------------
- # ● 颜色叠加(color)
- #--------------------------------------------------------------------------
- def color=(c)
- if @disposed
- raise(RGSSError,"disposed window")
- else
- @color = c
- update
- end
- end
- def color
- return @color
- end
- #--------------------------------------------------------------------------
- # ● 色调(tone)
- #--------------------------------------------------------------------------
- def tone=(tone)
- if @disposed
- raise(RGSSError,"disposed window")
- else
- @tone = tone
- update
- end
- end
- def tone
- return @tone
- end
- #--------------------------------------------------------------------------
- # ● 是否可见(visible)
- #--------------------------------------------------------------------------
- def visible=(v)
- if @disposed
- raise(RGSSError,"disposed window")
- else
- @visible = v
- update
- end
- end
- def visible
- return @visible
- end
- #--------------------------------------------------------------------------
- # ● 叠加模式(blend_type)
- #--------------------------------------------------------------------------
- def blend_type=(bt)
- if @disposed
- raise(RGSSError,"disposed window")
- else
- @blend_type = bt
- update
- end
- end
- def blend_type
- return @blend_type
- end
- #--------------------------------------------------------------------------
- # ● 释放内存(dispose)
- #--------------------------------------------------------------------------
- def dispose
- return if @dispose
- @dispose = true
- @contents.dispose
- @contents.bitmap.dispose if @contents.bitmap
- @bitmap.dispose
- end
- #--------------------------------------------------------------------------
- # ● 检测释放(dispose?)
- #--------------------------------------------------------------------------
- def dispose?
- @dispose
- end
- #--------------------------------------------------------------------------
- # ● 计算Plane的长宽与精灵排布(count_wh)
- #--------------------------------------------------------------------------
- def count_wh
- if @bitmap != nil
- @n_w = @rect.width / (@bitmap.width * @zoom_x).to_i + 3
- @n_h = @rect.height / (@bitmap.height * @zoom_y).to_i + 3
- h = @n_h * (@bitmap.height * @zoom_y).to_i
- w = @n_w * (@bitmap.width * @zoom_x).to_i
- if @contents.bitmap == nil
- @contents.bitmap = Bitmap.new(w, h)
- end
- for x in 0..@n_w
- for y in 0..@n_h
- rect = Rect.new(0,0,@bitmap.width * @zoom_x,@bitmap.height * @zoom_y)
- dest_rect = Rect.new(x * @bitmap.width * @zoom_x,\
- y * @bitmap.height * @zoom_y,@bitmap.width * @zoom_x,\
- @bitmap.height * @zoom_y)
- @contents.bitmap.stretch_blt(dest_rect, @bitmap, rect)
- end
- end
- end
- end
- end
复制代码 |
评分
-
查看全部评分
|