Project1
标题: 菜單教程的 if cn[0] == "[ DISCUZ_CODE_84 ]quot; [打印本页]
作者: lanlan1923 时间: 2015-4-12 01:01
标题: 菜單教程的 if cn[0] == "[ DISCUZ_CODE_84 ]quot;
本帖最后由 lanlan1923 于 2015-4-12 01:04 编辑
https://rpg.blue/thread-323665-1-1.html
想請問這個教程裡的描繪選項的部分
cn = $game_actors[@list[index][:ext]].character_name
ci = $game_actors[@list[index][:ext]].character_index
cb = Cache.character(cn)
if cn[0] == "[ DISCUZ_CODE_43 ]quot;
else
end
cn = $game_actors[@list[index][:ext]].character_name
ci = $game_actors[@list[index][:ext]].character_index
cb = Cache.character(cn)
if cn[0] == "[ DISCUZ_CODE_43 ]quot;
else
end
做到這一步時程式碼就變成紫色 再也沒辦法做下去了@@
就算抓下面改好的版本也一樣會出現紫色@@不知道是哪裡弄錯了?
謝謝
class Window_NewMenuStatus < Window_Command
#----------------------------------------------------------------------------
# * 初始化
#----------------------------------------------------------------------------
def initialize
super(160, 0)
end
#----------------------------------------------------------------------------
# * 获取窗口的宽度
#----------------------------------------------------------------------------
def window_width
return 384
end
#----------------------------------------------------------------------------
# * 获取窗口的高度
#----------------------------------------------------------------------------
def window_height
return 416
end
#----------------------------------------------------------------------------
# * 更新内容
#----------------------------------------------------------------------------
def refresh
super
draw_actor_status
end
#----------------------------------------------------------------------------
# * 生成指令列表
#----------------------------------------------------------------------------
def make_command_list
for actor in $game_party.members
s = "a[#{actor.id}]"
add_command(actor.name, s.to_sym, !actor.death_state?, actor.id)
end
end
#----------------------------------------------------------------------------
# * 描绘选项
#----------------------------------------------------------------------------
def draw_item(index)
rect = item_rect_for_text(index)
b = Bitmap.new(rect.width, rect.height)
cn = $game_actors[@list[index][:ext]].character_name
ci = $game_actors[@list[index][:ext]].character_index
cb = Cache.character(cn)
if cn[0] == "[ DISCUZ_CODE_84 ]quot;
cr = Rect.new
cr.x = cb.width / 3
cr.width = cb.width / 3
cr.height = cb.height / 4
else
cr = Rect.new
cr.x = ci % 4 * (cb.width / 4) + cb.width / 12
cr.y = ci / 4 * (cb.height / 2)
cr.width = cb.width / 12
cr.height = cb.height / 8
end
b.blt((b.width - cr.width) / 2, (b.height - cr.height) / 2, cb, cr)
unless command_enabled?(index)
for y in 0...b.height
for x in 0...b.width
next if b.get_pixel(x, y).alpha == 0
c = b.get_pixel(x, y)
m = (c.red + c.green + c.blue) / 3
b.set_pixel(x, y, Color.new(m, m, m, c.alpha))
end
end
end
self.contents.blt(rect.x, rect.y, b, b.rect)
b.dispose
cb.dispose
end
#----------------------------------------------------------------------------
# * 获取项目的绘制矩形
#----------------------------------------------------------------------------
def item_rect(index)
rect = Rect.new
rect.width = self.contents.width / 4
rect.height = 48
rect.x = (index < 4 ? index * rect.width : (index - 4) * rect.width)
rect.y = (index < 4 ? 0 : self.contents.height - rect.height)
return rect
end
#----------------------------------------------------------------------------
# * 描绘角色的状态
#----------------------------------------------------------------------------
def draw_actor_status
actor = $game_actors[@list[@index][:ext]]
y = item_rect_for_text(0).height + 5
h = self.contents.height - 2 * (item_rect_for_text(0).height + 5)
self.contents.clear_rect(Rect.new(0, y, self.contents.width, h))
draw_actor_face(actor, 0, y)
draw_actor_name(actor, 0, y)
draw_actor_level(actor, 96, y)
draw_actor_nickname(actor, 168, y)
draw_actor_hp(actor, 96, y + line_height, self.contents.width - 96)
draw_actor_mp(actor, 96, y + 2 * line_height, self.contents.width - 96)
draw_actor_icons(actor, 96, y + 3 * line_height)
for i in 0...6
draw_actor_param(actor, 0, y + (4 + i) * line_height, i)
end
for i in 0...5
draw_item_name(actor.equips[i], self.contents.width / 2, y + (4 + i) * line_height) if actor.equips[i] != nil
end
end
#----------------------------------------------------------------------------
# * 选择项目
#----------------------------------------------------------------------------
def select(index)
super
draw_actor_status
end
end
class Window_NewMenuStatus < Window_Command
#----------------------------------------------------------------------------
# * 初始化
#----------------------------------------------------------------------------
def initialize
super(160, 0)
end
#----------------------------------------------------------------------------
# * 获取窗口的宽度
#----------------------------------------------------------------------------
def window_width
return 384
end
#----------------------------------------------------------------------------
# * 获取窗口的高度
#----------------------------------------------------------------------------
def window_height
return 416
end
#----------------------------------------------------------------------------
# * 更新内容
#----------------------------------------------------------------------------
def refresh
super
draw_actor_status
end
#----------------------------------------------------------------------------
# * 生成指令列表
#----------------------------------------------------------------------------
def make_command_list
for actor in $game_party.members
s = "a[#{actor.id}]"
add_command(actor.name, s.to_sym, !actor.death_state?, actor.id)
end
end
#----------------------------------------------------------------------------
# * 描绘选项
#----------------------------------------------------------------------------
def draw_item(index)
rect = item_rect_for_text(index)
b = Bitmap.new(rect.width, rect.height)
cn = $game_actors[@list[index][:ext]].character_name
ci = $game_actors[@list[index][:ext]].character_index
cb = Cache.character(cn)
if cn[0] == "[ DISCUZ_CODE_84 ]quot;
cr = Rect.new
cr.x = cb.width / 3
cr.width = cb.width / 3
cr.height = cb.height / 4
else
cr = Rect.new
cr.x = ci % 4 * (cb.width / 4) + cb.width / 12
cr.y = ci / 4 * (cb.height / 2)
cr.width = cb.width / 12
cr.height = cb.height / 8
end
b.blt((b.width - cr.width) / 2, (b.height - cr.height) / 2, cb, cr)
unless command_enabled?(index)
for y in 0...b.height
for x in 0...b.width
next if b.get_pixel(x, y).alpha == 0
c = b.get_pixel(x, y)
m = (c.red + c.green + c.blue) / 3
b.set_pixel(x, y, Color.new(m, m, m, c.alpha))
end
end
end
self.contents.blt(rect.x, rect.y, b, b.rect)
b.dispose
cb.dispose
end
#----------------------------------------------------------------------------
# * 获取项目的绘制矩形
#----------------------------------------------------------------------------
def item_rect(index)
rect = Rect.new
rect.width = self.contents.width / 4
rect.height = 48
rect.x = (index < 4 ? index * rect.width : (index - 4) * rect.width)
rect.y = (index < 4 ? 0 : self.contents.height - rect.height)
return rect
end
#----------------------------------------------------------------------------
# * 描绘角色的状态
#----------------------------------------------------------------------------
def draw_actor_status
actor = $game_actors[@list[@index][:ext]]
y = item_rect_for_text(0).height + 5
h = self.contents.height - 2 * (item_rect_for_text(0).height + 5)
self.contents.clear_rect(Rect.new(0, y, self.contents.width, h))
draw_actor_face(actor, 0, y)
draw_actor_name(actor, 0, y)
draw_actor_level(actor, 96, y)
draw_actor_nickname(actor, 168, y)
draw_actor_hp(actor, 96, y + line_height, self.contents.width - 96)
draw_actor_mp(actor, 96, y + 2 * line_height, self.contents.width - 96)
draw_actor_icons(actor, 96, y + 3 * line_height)
for i in 0...6
draw_actor_param(actor, 0, y + (4 + i) * line_height, i)
end
for i in 0...5
draw_item_name(actor.equips[i], self.contents.width / 2, y + (4 + i) * line_height) if actor.equips[i] != nil
end
end
#----------------------------------------------------------------------------
# * 选择项目
#----------------------------------------------------------------------------
def select(index)
super
draw_actor_status
end
end
作者: VIPArcher 时间: 2015-4-12 01:18
本帖最后由 VIPArcher 于 2015-4-12 01:19 编辑
这个是老版本论坛代码解析带来的错误。
估计正确的是这样的
class Window_NewMenuStatus < Window_Command
#----------------------------------------------------------------------------
# * 初始化
#----------------------------------------------------------------------------
def initialize
super(160, 0)
end
#----------------------------------------------------------------------------
# * 获取窗口的宽度
#----------------------------------------------------------------------------
def window_width
return 384
end
#----------------------------------------------------------------------------
# * 获取窗口的高度
#----------------------------------------------------------------------------
def window_height
return 416
end
#----------------------------------------------------------------------------
# * 更新内容
#----------------------------------------------------------------------------
def refresh
super
draw_actor_status
end
#----------------------------------------------------------------------------
# * 生成指令列表
#----------------------------------------------------------------------------
def make_command_list
for actor in $game_party.members
s = "a[#{actor.id}]"
add_command(actor.name, s.to_sym, !actor.death_state?, actor.id)
end
end
#----------------------------------------------------------------------------
# * 描绘选项
#----------------------------------------------------------------------------
def draw_item(index)
rect = item_rect_for_text(index)
b = Bitmap.new(rect.width, rect.height)
cn = $game_actors[@list[index][:ext]].character_name
ci = $game_actors[@list[index][:ext]].character_index
cb = Cache.character(cn)
if cn[0] == "$"
cr = Rect.new
cr.x = cb.width / 3
cr.width = cb.width / 3
cr.height = cb.height / 4
else
cr = Rect.new
cr.x = ci % 4 * (cb.width / 4) + cb.width / 12
cr.y = ci / 4 * (cb.height / 2)
cr.width = cb.width / 12
cr.height = cb.height / 8
end
b.blt((b.width - cr.width) / 2, (b.height - cr.height) / 2, cb, cr)
unless command_enabled?(index)
for y in 0...b.height
for x in 0...b.width
next if b.get_pixel(x, y).alpha == 0
c = b.get_pixel(x, y)
m = (c.red + c.green + c.blue) / 3
b.set_pixel(x, y, Color.new(m, m, m, c.alpha))
end
end
end
self.contents.blt(rect.x, rect.y, b, b.rect)
b.dispose
cb.dispose
end
#----------------------------------------------------------------------------
# * 获取项目的绘制矩形
#----------------------------------------------------------------------------
def item_rect(index)
rect = Rect.new
rect.width = self.contents.width / 4
rect.height = 48
rect.x = (index < 4 ? index * rect.width : (index - 4) * rect.width)
rect.y = (index < 4 ? 0 : self.contents.height - rect.height)
return rect
end
#----------------------------------------------------------------------------
# * 描绘角色的状态
#----------------------------------------------------------------------------
def draw_actor_status
actor = $game_actors[@list[@index][:ext]]
y = item_rect_for_text(0).height + 5
h = self.contents.height - 2 * (item_rect_for_text(0).height + 5)
self.contents.clear_rect(Rect.new(0, y, self.contents.width, h))
draw_actor_face(actor, 0, y)
draw_actor_name(actor, 0, y)
draw_actor_level(actor, 96, y)
draw_actor_nickname(actor, 168, y)
draw_actor_hp(actor, 96, y + line_height, self.contents.width - 96)
draw_actor_mp(actor, 96, y + 2 * line_height, self.contents.width - 96)
draw_actor_icons(actor, 96, y + 3 * line_height)
for i in 0...6
draw_actor_param(actor, 0, y + (4 + i) * line_height, i)
end
for i in 0...5
draw_item_name(actor.equips[i], self.contents.width / 2, y + (4 + i) * line_height) if actor.equips[i] != nil
end
end
#----------------------------------------------------------------------------
# * 选择项目
#----------------------------------------------------------------------------
def select(index)
super
draw_actor_status
end
end
class Window_NewMenuStatus < Window_Command
#----------------------------------------------------------------------------
# * 初始化
#----------------------------------------------------------------------------
def initialize
super(160, 0)
end
#----------------------------------------------------------------------------
# * 获取窗口的宽度
#----------------------------------------------------------------------------
def window_width
return 384
end
#----------------------------------------------------------------------------
# * 获取窗口的高度
#----------------------------------------------------------------------------
def window_height
return 416
end
#----------------------------------------------------------------------------
# * 更新内容
#----------------------------------------------------------------------------
def refresh
super
draw_actor_status
end
#----------------------------------------------------------------------------
# * 生成指令列表
#----------------------------------------------------------------------------
def make_command_list
for actor in $game_party.members
s = "a[#{actor.id}]"
add_command(actor.name, s.to_sym, !actor.death_state?, actor.id)
end
end
#----------------------------------------------------------------------------
# * 描绘选项
#----------------------------------------------------------------------------
def draw_item(index)
rect = item_rect_for_text(index)
b = Bitmap.new(rect.width, rect.height)
cn = $game_actors[@list[index][:ext]].character_name
ci = $game_actors[@list[index][:ext]].character_index
cb = Cache.character(cn)
if cn[0] == "$"
cr = Rect.new
cr.x = cb.width / 3
cr.width = cb.width / 3
cr.height = cb.height / 4
else
cr = Rect.new
cr.x = ci % 4 * (cb.width / 4) + cb.width / 12
cr.y = ci / 4 * (cb.height / 2)
cr.width = cb.width / 12
cr.height = cb.height / 8
end
b.blt((b.width - cr.width) / 2, (b.height - cr.height) / 2, cb, cr)
unless command_enabled?(index)
for y in 0...b.height
for x in 0...b.width
next if b.get_pixel(x, y).alpha == 0
c = b.get_pixel(x, y)
m = (c.red + c.green + c.blue) / 3
b.set_pixel(x, y, Color.new(m, m, m, c.alpha))
end
end
end
self.contents.blt(rect.x, rect.y, b, b.rect)
b.dispose
cb.dispose
end
#----------------------------------------------------------------------------
# * 获取项目的绘制矩形
#----------------------------------------------------------------------------
def item_rect(index)
rect = Rect.new
rect.width = self.contents.width / 4
rect.height = 48
rect.x = (index < 4 ? index * rect.width : (index - 4) * rect.width)
rect.y = (index < 4 ? 0 : self.contents.height - rect.height)
return rect
end
#----------------------------------------------------------------------------
# * 描绘角色的状态
#----------------------------------------------------------------------------
def draw_actor_status
actor = $game_actors[@list[@index][:ext]]
y = item_rect_for_text(0).height + 5
h = self.contents.height - 2 * (item_rect_for_text(0).height + 5)
self.contents.clear_rect(Rect.new(0, y, self.contents.width, h))
draw_actor_face(actor, 0, y)
draw_actor_name(actor, 0, y)
draw_actor_level(actor, 96, y)
draw_actor_nickname(actor, 168, y)
draw_actor_hp(actor, 96, y + line_height, self.contents.width - 96)
draw_actor_mp(actor, 96, y + 2 * line_height, self.contents.width - 96)
draw_actor_icons(actor, 96, y + 3 * line_height)
for i in 0...6
draw_actor_param(actor, 0, y + (4 + i) * line_height, i)
end
for i in 0...5
draw_item_name(actor.equips[i], self.contents.width / 2, y + (4 + i) * line_height) if actor.equips[i] != nil
end
end
#----------------------------------------------------------------------------
# * 选择项目
#----------------------------------------------------------------------------
def select(index)
super
draw_actor_status
end
end
未测试
欢迎光临 Project1 (https://rpg.blue/) |
Powered by Discuz! X3.1 |