Project1
标题: 又来发帖,寻 加强command_window 图片坐标版效果 [打印本页]
作者: 勇敢的馒头 时间: 2012-10-22 11:54
标题: 又来发帖,寻 加强command_window 图片坐标版效果
本帖最后由 勇敢的馒头 于 2012-10-22 21:47 编辑
有找到站内的 加强command_window
http://www.66rpg.com/articles/3082
主要是添加个分歧,选择的效果和未选择时的效果
现在我想改变图片,比如 Window_MenuStatus 窗口,使选框经过的 角色的行走图Y坐标-1,该如何修改?
是修改Window_Selectable吗?但是Window_Selectable只是一个图形盖在上面的啊~~
作者: 沙漠点灰 时间: 2012-10-22 19:59
看来lz多多少少懂点脚本,就写写过程:
Window_MenuStatus中可以发现有行
draw_actor_graphic(actor, x - 40, y + 80)
draw_actor_graphic的定义lz可以看看它父类的定义
2个参数,x,y
你需要y坐标在选中,即
@index = 角色在队伍编号 时
y坐标 = y + 79
否则
y坐标 = y + 80
可以了解,行走图占了 1*1.5的地图格(默认),为兼容大图,设为64*96
为提高效率,这点对于游戏程序尤为重要,所以采用局部刷新.
所以建立新的实例变量@index_old,用来记录原来的位置..实例变量初始就是nil值,这就可以偷下懒..
在原来- if @index < 0
- self.cursor_rect.empty
- else
- self.cursor_rect.set(0, @index * 116, self.width - 32, 96)
- end
复制代码 下面加个
refresh_choice if @index != @index_old
refresh_choice if @index != @index_old
新建方法 refresh_choice
这里主要是坐标计算,还有就是清空,
RMXP默认没有清空像素,只有用填充像素,即fill_rect,在color参数写Color.new(0,0,0,0)就行
定义如下:
def refresh_choice
color = Color.new(0,0,0,0)
if @index_old
self.contents.fill_rect(0, @index_old*116, 64, 96, color)
draw_actor_graphic($game_party.actors[@index_old], 24, @index_old*116+80)
end
self.contents.fill_rect(0, @index *116, 64, 96, color)
draw_actor_graphic($game_party.actors[@index], 24, @index*116+75)
@index_old = @index
end
def refresh_choice
color = Color.new(0,0,0,0)
if @index_old
self.contents.fill_rect(0, @index_old*116, 64, 96, color)
draw_actor_graphic($game_party.actors[@index_old], 24, @index_old*116+80)
end
self.contents.fill_rect(0, @index *116, 64, 96, color)
draw_actor_graphic($game_party.actors[@index], 24, @index*116+75)
@index_old = @index
end
1像素太小了,我写了5像素
Window_MenuStatus现在变成了:
#==============================================================================
# ■ Window_MenuStatus
#------------------------------------------------------------------------------
# 显示菜单画面和同伴状态的窗口。
#==============================================================================
class Window_MenuStatus < Window_Selectable
#--------------------------------------------------------------------------
# ● 初始化目标
#--------------------------------------------------------------------------
def initialize
super(0, 0, 480, 480)
self.contents = Bitmap.new(width - 32, height - 32)
refresh
self.active = false
self.index = -1
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
self.contents.clear
@item_max = $game_party.actors.size
for i in 0...$game_party.actors.size
x = 64
y = i * 116
actor = $game_party.actors[i]
draw_actor_graphic(actor, x - 40, y + 80)
draw_actor_name(actor, x, y)
draw_actor_class(actor, x + 144, y)
draw_actor_level(actor, x, y + 32)
draw_actor_state(actor, x + 90, y + 32)
draw_actor_exp(actor, x, y + 64)
draw_actor_hp(actor, x + 236, y + 32)
draw_actor_sp(actor, x + 236, y + 64)
end
end
#--------------------------------------------------------------------------
# ● 刷新光标矩形
#--------------------------------------------------------------------------
def update_cursor_rect
if @index < 0
self.cursor_rect.empty
else
self.cursor_rect.set(0, @index * 116, self.width - 32, 96)
end
refresh_choice if @index != @index_old and @index >= 0
end
#--------------------------------------------------------------------------
# ● 局部刷新
#--------------------------------------------------------------------------
def refresh_choice
color = Color.new(0,0,0,0)
if @index_old
self.contents.fill_rect(0, @index_old*116, 64, 96, color)
draw_actor_graphic($game_party.actors[@index_old], 24, @index_old*116+80)
end
self.contents.fill_rect(0, @index *116, 64, 96, color)
draw_actor_graphic($game_party.actors[@index], 24, @index*116+75)
@index_old = @index
end
end
#==============================================================================
# ■ Window_MenuStatus
#------------------------------------------------------------------------------
# 显示菜单画面和同伴状态的窗口。
#==============================================================================
class Window_MenuStatus < Window_Selectable
#--------------------------------------------------------------------------
# ● 初始化目标
#--------------------------------------------------------------------------
def initialize
super(0, 0, 480, 480)
self.contents = Bitmap.new(width - 32, height - 32)
refresh
self.active = false
self.index = -1
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
self.contents.clear
@item_max = $game_party.actors.size
for i in 0...$game_party.actors.size
x = 64
y = i * 116
actor = $game_party.actors[i]
draw_actor_graphic(actor, x - 40, y + 80)
draw_actor_name(actor, x, y)
draw_actor_class(actor, x + 144, y)
draw_actor_level(actor, x, y + 32)
draw_actor_state(actor, x + 90, y + 32)
draw_actor_exp(actor, x, y + 64)
draw_actor_hp(actor, x + 236, y + 32)
draw_actor_sp(actor, x + 236, y + 64)
end
end
#--------------------------------------------------------------------------
# ● 刷新光标矩形
#--------------------------------------------------------------------------
def update_cursor_rect
if @index < 0
self.cursor_rect.empty
else
self.cursor_rect.set(0, @index * 116, self.width - 32, 96)
end
refresh_choice if @index != @index_old and @index >= 0
end
#--------------------------------------------------------------------------
# ● 局部刷新
#--------------------------------------------------------------------------
def refresh_choice
color = Color.new(0,0,0,0)
if @index_old
self.contents.fill_rect(0, @index_old*116, 64, 96, color)
draw_actor_graphic($game_party.actors[@index_old], 24, @index_old*116+80)
end
self.contents.fill_rect(0, @index *116, 64, 96, color)
draw_actor_graphic($game_party.actors[@index], 24, @index*116+75)
@index_old = @index
end
end
这样就好了
作者: 勇敢的馒头 时间: 2012-10-22 21:46
沙漠点灰 发表于 2012-10-22 19:59
看来lz多多少少懂点脚本,就写写过程:
Window_MenuStatus中可以发现有行
原来如此,看明白了,感谢回答还给出如此详细的说明~
欢迎光临 Project1 (https://rpg.blue/) |
Powered by Discuz! X3.1 |