Project1
标题:
定义一个窗口的背景图片
[打印本页]
作者:
200878242
时间:
2008-12-4 03:53
标题:
定义一个窗口的背景图片
怎么给一个窗口定义一个图片,就是不显示窗口外观图形,而是要显示自己要的背景图片 [LINE]1,#dddddd[/LINE]
版务信息:本贴由楼主自主结贴~
作者:
redant
时间:
2008-12-4 04:06
@sprite = Sprite.new
@sprite.bitmap = RPG::Cache.picture("【任务】寻#{$game_variables[49]}.png")
加图片
self.windowskin = RPG::Cache.windowskin("../system/menu/windowskins/palskin")
self.opacity = 0
边框不显示
[LINE]1,#dddddd[/LINE]
系统信息:本贴由楼主认可为正确答案,66RPG感谢您的热情解答~
作者:
200878242
时间:
2008-12-4 04:25
加载最上面吗
作者:
redant
时间:
2008-12-4 04:33
加图片 放在刷新里
不显示边框在 initialize里
作者:
八云紫
时间:
2008-12-4 04:34
以下引用
redant于2008-12-3 20:33:00
的发言:
加图片 放在刷新里
不显示边框在 initialize里
小声: 图片 不需要刷新的呀, 其实加在 initialize 更好的~~~~~{/hx}
作者:
200878242
时间:
2008-12-4 04:52
下面的脚本怎么给窗口加一个背景图片
class Window_BattleResult < Window_Base
#--------------------------------------------------------------------------
# ● 初始化对像
# exp : EXP
# gold : 金钱
# treasures : 宝物
#--------------------------------------------------------------------------
def initialize(exp, gold, treasures)
@exp = exp
@gold = gold
@treasures = treasures
@expup = []
@expnow = []
for i in 0...$game_party.actors.size
actor = $game_party.actors[i]
now = actor.now_exp
max = actor.next_exp
now = now > max ? max : now
@expnow[i] = max != 0 ? 98 * now / max.to_f : 0
now2 = actor.now_exp - @exp
now2 = now2 > max ? max : now2
@expup[i] = max != 0 ? 98 * now2 / max.to_f : 0
end
super(120, 0, 400, 8* 32 + 120)
self.contents = Bitmap.new(width - 32, height - 32)
self.y = 188 - height / 2
self.back_opacity = 188
self.visible = false
refresh
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
self.contents.clear
@item_max = $game_party.actors.size
for i in 0...$game_party.actors.size
x = 64
y = i * 80
actor = $game_party.actors[i]
bitmap = Bitmap.new("Graphics/LVUP/" + actor.name + "_save.png")
src_rect = Rect.new(0, 0, 600, 600)
self.contents.blt(x -64, y +17, bitmap, src_rect)
self.draw_actor_state(actor, x - 64, y + 2 + 17)
# 我全写成散的! =。=
self.contents.font.color = normal_color
self.contents.font.size = 19
self.contents.font.color = system_color
self.contents.font.color = normal_color
self.contents.font.size = 19
self.contents.font.color = system_color
draw_actor_hp(actor,x+2,y+5+14,100)
draw_actor_sp(actor,x+2,y+5+14+18,100)
self.contents.font.color = system_color
self.contents.draw_text(x, y,150, 144, "经验值")
self.contents.font.color = normal_color
self.contents.draw_text(x + 15, y, 84, 144, actor.now_exp.to_s, 2)
end
x = 3
self.contents.font.color = normal_color
cx = contents.text_size("战斗结束:").width
self.contents.draw_text(138,0,200, 20, "战斗结束:")
x = 6
self.contents.font.color = normal_color
cx = contents.text_size( @exp.to_s).width
self.contents.draw_text(300,0,128, 530, @exp.to_s)
x += cx + 16
self.contents.font.color = normal_color
cx = contents.text_size(@gold.to_s).width
self.contents.draw_text(300,0,128, 570, @gold.to_s)
cx = contents.text_size($data_system.words.gold).width
for i in 0...$game_party.actors.size
actor = $game_party.actors[i]
self.contents.fill_rect(66, i*81+79, 100, 8,Color.new(64, 0, 0, 192))
self.contents.fill_rect(68, i*81+81, 96, 4, Color.new(255, 255, 192, 192))
now = actor.now_exp - @exp
max = actor.next_exp
now = now > max ? max : now
a = max != 0 ? 78 * now / max.to_f : 0
self.contents.fill_rect(67, i*81+80, @expup[i], 6, Color.new(217,168,0,255))
end
y = 32
for item in @treasures
draw_item_name(item, 180, y+20)
y += 32
end
end
def update
for i in 0...$game_party.actors.size
if @expup[i] < @expnow[i]
@expup[i] += 1
end
end
refresh
end
end
class Game_Actor < Game_Battler
def now_exp
return @exp - @exp_list[@level]
end
def next_exp
return @exp_list[@level+1] > 0 ? @exp_list[@level+1] - @exp_list[@level] : 0
end
end
class Scene_Battle
def update
# 执行战斗事件中的情况下
if $game_system.battle_interpreter.running?
# 刷新解释器
$game_system.battle_interpreter.update
# 强制行动的战斗者不存在的情况下
if $game_temp.forcing_battler == nil
# 执行战斗事件结束的情况下
unless $game_system.battle_interpreter.running?
# 继续战斗的情况下、再执行战斗事件的设置
unless judge
setup_battle_event
end
end
# 如果不是结束战斗回合的情况下
if @phase != 5
# 刷新状态窗口
@status_window.refresh
end
end
end
# 系统 (计时器)、刷新画面
$game_system.update
$game_screen.update
# 计时器为 0 的情况下
if $game_system.timer_working and $game_system.timer == 0
# 中断战斗
$game_temp.battle_abort = true
end
# 刷新窗口
@help_window.update
@party_command_window.update
@actor_command_window.update
@status_window.update
@message_window.update
#####################
if @result_window != nil
@result_window.update
end
###################################
# 刷新活动块
@spriteset.update
# 处理过渡中的情况下
if $game_temp.transition_processing
# 清除处理过渡中标志
$game_temp.transition_processing = false
# 执行过渡
if $game_temp.transition_name == ""
Graphics.transition(20)
else
Graphics.transition(40, "Graphics/Transitions/" +
$game_temp.transition_name)
end
end
# 显示信息窗口中的情况下
if $game_temp.message_window_showing
return
end
# 显示效果中的情况下
if @spriteset.effect?
return
end
# 游戏结束的情况下
if $game_temp.gameover
# 切换到游戏结束画面
$scene = Scene_Gameover.new
return
end
# 返回标题画面的情况下
if $game_temp.to_title
# 切换到标题画面
$scene = Scene_Title.new
return
end
# 中断战斗的情况下
if $game_temp.battle_abort
# 还原为战斗前的 BGM
$game_system.bgm_play($game_temp.map_bgm)
# 战斗结束
battle_end(1)
return
end
# 等待中的情况下
if @wait_count > 0
# 减少等待计数
@wait_count -= 1
return
end
# 强制行动的角色存在、
# 并且战斗事件正在执行的情况下
if $game_temp.forcing_battler == nil and
$game_system.battle_interpreter.running?
return
end
# 回合分支
case @phase
when 1 # 自由战斗回合
update_phase1
when 2 # 同伴命令回合
update_phase2
when 3 # 角色命令回合
update_phase3
when 4 # 主回合
update_phase4
when 5 # 战斗结束回合
update_phase5
end
end
def start_phase5
# 转移到回合 5
@phase = 5
# 演奏战斗结束 ME
$game_system.me_play($game_system.battle_end_me)
# 还原为战斗开始前的 BGM
$game_system.bgm_play($game_temp.map_bgm)
# 初始化 EXP、金钱、宝物
exp = 0
gold = 0
treasures = []
# 循环
for enemy in $game_troop.enemies
# 敌人不是隐藏状态的情况下
unless enemy.hidden
# 获得 EXP、增加金钱
exp += enemy.exp
gold += enemy.gold
# 出现宝物判定
if rand(100) < enemy.treasure_prob
if enemy.item_id > 0
treasures.push($data_items[enemy.item_id])
end
if enemy.weapon_id > 0
treasures.push($data_weapons[enemy.weapon_id])
end
if enemy.armor_id > 0
treasures.push($data_armors[enemy.armor_id])
end
end
end
end
# 限制宝物数为 6 个
treasures = treasures[0..5]
# 获得 EXP
for i in 0...$game_party.actors.size
actor = $game_party.actors[i]
if actor.cant_get_exp? == false
last_level = actor.level
actor.exp += exp
if actor.level > last_level
@status_window.level_up(i)
end
end
end
# 获得金钱
$game_party.gain_gold(gold)
# 获得宝物
for item in treasures
case item
when RPG::Item
$game_party.gain_item(item.id, 1)
when RPG::Weapon
$game_party.gain_weapon(item.id, 1)
when RPG::Armor
$game_party.gain_armor(item.id, 1)
end
end
# 生成战斗结果窗口
@result_window = Window_BattleResult.new(exp, gold, treasures)
#####################
@result_window.visible = true
###################################
# 设置等待计数
@phase5_wait_count = 100
end
end
复制代码
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1