| 赞 | 1 |
| VIP | |
| 好人卡 | |
| 积分 | 1 |
| 经验 | |
| 最后登录 | 2015-1-15 |
| 在线时间 | 323 小时 |
- 梦石
- 0
- 星屑
- 55
- 在线时间
- 323 小时
- 注册时间
- 2010-8-21
- 回帖
- 638
|
发表于 2013-5-12 13:13:17
|
显示全部楼层
脚本里找个位置,最好就是第一个
[pre lang="ruby" line="1"]module Math
def self.f(x)
return self.f(x+1) if x < 0
return self.f(x-1) if x > 2
(x-1)**2
end
end
class Window_Base
#--------------------------------------------------------------------------
# ● 移动到
#--------------------------------------------------------------------------
def move_to(x, y,duration, opa=nil)
@old_x = self.x
@old_y = self.y
@target_x = (x ? x : self.x)
@target_y = (y ? y : self.y)
@target_opa = (opa ? opa : @target_opa)
@old_opa = self.opacity
@duration = duration
@duration_full = duration.to_f
end
#--------------------------------------------------------------------------
# ● 刷新移动
#--------------------------------------------------------------------------
def move_update
return true if @duration.nil? or @duration <= 0
@duration -= 1
var = 1-Math.f(@duration/@duration_full+1)
self.x = (@old_x + (@target_x-@old_x) *var+0.5).to_i
self.y = (@old_y + (@target_y-@old_y) *var+0.5).to_i
self.opacity = @old_opa + (@target_opa - @old_opa)*var if @target_opa
self.contents_opacity = self.opacity
false
end
end
[/pre]
找到Scene_Map的update方法,里面加一句update_diy_windows
再在main前加上:
[pre lang="ruby" line="1"]class Scene_Map
def update_diy_windows
@diy_windows ||= []
@diy_windows.each{|wnd|wnd.move_update;wnd.update}
end
def add_diy_window(wnd)
@diy_windows ||= []
@diy_windows << wnd
end
def dispose_diy_window(wnd)
@diy_windows ||= []
@diy_windows.delete(wnd)
wnd.dispose
end
end[/pre]
使用方法,如lz写得那样,但是本脚本只在地图上有效,其他地方(如战斗时)使用会出错.
$test = Window_Base.new(20, 20, 800, 48)
$test.contents.draw_text(0, 0, 800, 30, "测试", 0)
SceneManager.scene.add_diy_window($test)
$test.opacity = 0
$test.contents_opacity = 0
$test.move_to(nil, nil, 300, 255)
就能在300内将窗口从透明变为不透明。
$test.move_to(500, 20, 30, 255)
就能在300内将窗口从原位置移动到(500, 20)透明变为不透明。
$test.move_to(500, nil, 30, 255)
$test.move_to(nil, 500, 30, 255)
这个lz可以试试
释放窗口使用:
SceneManager.scene.dispose_diy_window($test)
就行,没试过,可能有错 |
|