Project1
标题: 怎么获取敌人的战斗图像?? [打印本页]
作者: 布罗利 时间: 2014-10-25 13:42
标题: 怎么获取敌人的战斗图像??
本帖最后由 布罗利 于 2014-10-25 13:44 编辑
我正在弄一个赏金系统(就是打死怪物后不能直接获得金钱,得到相应的地方领取)
金钱数值的处理已经完成了,我想让画面华丽一点,把已经打败的怪物全部都显示出来,然后在获得金钱
如图:
大概就是这样的效果
只是敌人的战斗图,金钱的数值我都弄好了
求给个思路,范例什么的
先谢谢了
@美丽晨露
@RyanBern
@芯☆淡茹水
作者: cinderelmini 时间: 2014-10-25 13:52
思路就是选一个全局变量($game_party,$game_system什么的都可以),新建一个数组a,
之后在Scene_Battle里建一个数组b,战斗开始的时候把所有敌人复制一份塞进这个数组,
战斗结束,胜利的场合,把数组b的内容一个个push进数组a,
在交付界面的时候数组a里面就是已经打败的敌人集合了~
之后要怎么处理楼下来接上吗?
反正交付完成后数组a是要清空一下~
作者: 美丽晨露 时间: 2014-10-25 18:11
魔女的VX工程也有类似的悬赏事件。
主要是用脚本太麻烦了。
魔女的做法是:
1.将通缉令用PS事先做好
2.在游戏工程中,NPC(墙角照片)事件显示图片——通缉令(未击破)
3.打败该通缉者打开某开关
4.在NPC(墙角照片)事件显示图片——通缉令(已击破)
5.以上用到的是明雷遇怪效果哟。
当然,2楼前辈的做法可能比魔女要好得多。
你参考一下她的说明试试看也会不错的说。
作者: 芯☆淡茹水 时间: 2014-10-25 19:04
每个小怪都有!那就需要额外储存,在战斗胜利时记数。
并且还要显示,弄起来有点麻烦。
作者: RyanBern 时间: 2014-10-25 19:44
本帖最后由 RyanBern 于 2014-10-25 21:03 编辑
2L已经说明,必须要记录打败敌人的数量,这点可以在$game_system里面开一个Hash表(和2L不同,这里用的是Hash表而不是数组,这是模仿游戏存储道具的数据结构设定)。然后就是在每次战斗结束后对此Hash表进行操作即可。然后就是敌人战斗图的显示,可以利用$data_enemies[id].batter_name来获取战斗图名字。下面是一个简易的窗口,由于战斗图大小各异,所以请保证战斗图大小一致,否则会引起排版错乱。这里默认战斗图是100*100。
不知道你用的什么办法计算最终得到金钱的数量的,只能做到这一步了。战斗结束时自动记录敌人,打开这个界面后,按Esc退出金钱自动会增加。
我这里没有闪退的问题,不知道你改了哪里。
#===============================================================================
# ■ Scene_赏金系统
#-------------------------------------------------------------------------------
# 处理赏金画面的类
#===============================================================================
class Scene_赏金系统
#--------------------------------------------------------------------------
# ● 主处理
#--------------------------------------------------------------------------
def main
@sprite=Sprite.new
@sprite.bitmap=RPG::Cache.picture("赏金背景")
@enemy_window = Window_Enemy.new
Graphics.transition
loop do
Graphics.update
Input.update
# 如果切换画面就中断循环
update
if $scene != self
break
end
end
# 准备过渡
Graphics.freeze
@sprite.dispose
@enemy_window.dispose
end
def update
if Input.trigger?(Input::B)
$game_system.clear_defeated
$game_party.gain_gold($kklt)
$kklt = 0
$scene = Scene_Map.new
return
end
end
end
#==============================================================================
class Game_System
alias rb_initialize_20141025 initialize
def initialize
@defeated_enemies = {}
rb_initialize_20141025
end
def defeated_enemy_number(enemy_id)
return @defeated_enemies[enemy_id] == nil ? 0 : @defeated_enemies[enemy_id]
end
def defeated_enemy_number_add(enemy_id, n)
@defeated_enemies[enemy_id] = [defeated_enemy_number(enemy_id) + n, 0].max
end
def clear_defeated
@defeated_enemies = {}
end
end
#==============================================================================
class Window_Enemy < Window_Base
def initialize
super(0, 0, 480, 480)
self.contents = Bitmap.new(width - 32, height - 32)
self.opacity = 0
refresh
end
def refresh
self.contents.clear
@data = []
(1...$data_enemies.size).each do |i|
if $game_system.defeated_enemy_number(i) > 0
@data.push($data_enemies[i])
end
end
self.contents.font.size = 36
@data.each_with_index do |enemy, i|
x = 4 + i % 2 * 240
y = i / 2 * 100
bitmap = RPG::Cache.battler(enemy.battler_name, enemy.battler_hue)
self.contents.blt(x, y, bitmap, Rect.new(0,0,100,100))
self.contents.draw_text(x + 104, y, 100, 100, "×" + $game_system.defeated_enemy_number(enemy.id).to_s, 2)
end
self.contents.draw_text(0, 400, 400-32, 64, $kklt.to_s + "G", 2)
end
end
class Scene_Battle
alias rb_battle_end battle_end
def battle_end(result)
if result == 0
$game_troop.enemies.each do |enemy|
$game_system.defeated_enemy_number_add(enemy.id, 1)
end
end
rb_battle_end(result)
end
end
#===============================================================================
# ■ Scene_赏金系统
#-------------------------------------------------------------------------------
# 处理赏金画面的类
#===============================================================================
class Scene_赏金系统
#--------------------------------------------------------------------------
# ● 主处理
#--------------------------------------------------------------------------
def main
@sprite=Sprite.new
@sprite.bitmap=RPG::Cache.picture("赏金背景")
@enemy_window = Window_Enemy.new
Graphics.transition
loop do
Graphics.update
Input.update
# 如果切换画面就中断循环
update
if $scene != self
break
end
end
# 准备过渡
Graphics.freeze
@sprite.dispose
@enemy_window.dispose
end
def update
if Input.trigger?(Input::B)
$game_system.clear_defeated
$game_party.gain_gold($kklt)
$kklt = 0
$scene = Scene_Map.new
return
end
end
end
#==============================================================================
class Game_System
alias rb_initialize_20141025 initialize
def initialize
@defeated_enemies = {}
rb_initialize_20141025
end
def defeated_enemy_number(enemy_id)
return @defeated_enemies[enemy_id] == nil ? 0 : @defeated_enemies[enemy_id]
end
def defeated_enemy_number_add(enemy_id, n)
@defeated_enemies[enemy_id] = [defeated_enemy_number(enemy_id) + n, 0].max
end
def clear_defeated
@defeated_enemies = {}
end
end
#==============================================================================
class Window_Enemy < Window_Base
def initialize
super(0, 0, 480, 480)
self.contents = Bitmap.new(width - 32, height - 32)
self.opacity = 0
refresh
end
def refresh
self.contents.clear
@data = []
(1...$data_enemies.size).each do |i|
if $game_system.defeated_enemy_number(i) > 0
@data.push($data_enemies[i])
end
end
self.contents.font.size = 36
@data.each_with_index do |enemy, i|
x = 4 + i % 2 * 240
y = i / 2 * 100
bitmap = RPG::Cache.battler(enemy.battler_name, enemy.battler_hue)
self.contents.blt(x, y, bitmap, Rect.new(0,0,100,100))
self.contents.draw_text(x + 104, y, 100, 100, "×" + $game_system.defeated_enemy_number(enemy.id).to_s, 2)
end
self.contents.draw_text(0, 400, 400-32, 64, $kklt.to_s + "G", 2)
end
end
class Scene_Battle
alias rb_battle_end battle_end
def battle_end(result)
if result == 0
$game_troop.enemies.each do |enemy|
$game_system.defeated_enemy_number_add(enemy.id, 1)
end
end
rb_battle_end(result)
end
end
作者: 布罗利 时间: 2014-10-25 20:08
本帖最后由 RyanBern 于 2014-10-25 20:27 编辑
RyanBern 发表于 2014-10-25 19:44
2L已经说明,必须要记录打败敌人的数量,这点可以在$game_system里面开一个Hash表(和2L不同,这里用的是Ha ...
完全看不懂,把你的脚本复制到我目前写的里,但是没有任何效果.帮看一下
#===============================================================================
# ■ Scene_赏金系统
#-------------------------------------------------------------------------------
# 处理赏金画面的类
#===============================================================================
class Scene_赏金系统
#--------------------------------------------------------------------------
# ● 主处理
#--------------------------------------------------------------------------
def main
@sprite=Sprite.new
@sprite.bitmap=RPG::Cache.picture("Graphics/Pictures/赏金系统.png")
@enemy_window = Window_Enemy.new
$game_party.gain_gold($kklt)
$kklt = 0
loop do
Graphics.update
Input.update
# 如果切换画面就中断循环
update
if $scene != self
break
end
end
# 准备过渡
Graphics.freeze
@sprite.dispose
@enemy_window.dispose
end
def update
if Input.trigger?(Input::B)
$scene = Scene_Map.new
return
end
end
end
#==============================================================================
class Game_System
alias rb_initialize_20141025 initialize
def initialize
@defeated_enemies = {}
rb_initialize_20141025
end
def defeated_enemy_number(enemy_id)
return @defeated_enemies[enemy_id] == nil ? 0 : @defeated_enemies[enemy_id]
end
def defeated_enemy_number_add(enemy_id, n)
@defeated_enemies[enemy_id] = [defeated_enemy_number(enemy_id) + n, 0].max
end
end
#==============================================================================
class Window_Enemy < Window_Base
def initialize
super(0, 0, 480, 480)
self.contents = Bitmap.new(width - 32, height - 32)
refresh
end
def refresh
self.contents.clear
@data = []
(1...$data_enemies.size).each do |i|
if $game_system.defeated_enemy_number(i) > 0
@data.push($data_enemies[i])
end
end
self.contents.font.size = 36
@data.each do |enemy|
x = 4 + i % 2 * 240
y = i / 2 * 100
bitmap = RPG::Cache.batter(enemy.battler_name, enemy.battler_hue)
self.contents.blt(x, y, bitmap, Rect.new(0,0,100,100))
self.contents.draw_text(x + 104, y, 100, 100, "×" + $game_system.defeated_enemy_number(enemy.id).to_s, 2)
end
end
end
#===============================================================================
# ■ Scene_赏金系统
#-------------------------------------------------------------------------------
# 处理赏金画面的类
#===============================================================================
class Scene_赏金系统
#--------------------------------------------------------------------------
# ● 主处理
#--------------------------------------------------------------------------
def main
@sprite=Sprite.new
@sprite.bitmap=RPG::Cache.picture("Graphics/Pictures/赏金系统.png")
@enemy_window = Window_Enemy.new
$game_party.gain_gold($kklt)
$kklt = 0
loop do
Graphics.update
Input.update
# 如果切换画面就中断循环
update
if $scene != self
break
end
end
# 准备过渡
Graphics.freeze
@sprite.dispose
@enemy_window.dispose
end
def update
if Input.trigger?(Input::B)
$scene = Scene_Map.new
return
end
end
end
#==============================================================================
class Game_System
alias rb_initialize_20141025 initialize
def initialize
@defeated_enemies = {}
rb_initialize_20141025
end
def defeated_enemy_number(enemy_id)
return @defeated_enemies[enemy_id] == nil ? 0 : @defeated_enemies[enemy_id]
end
def defeated_enemy_number_add(enemy_id, n)
@defeated_enemies[enemy_id] = [defeated_enemy_number(enemy_id) + n, 0].max
end
end
#==============================================================================
class Window_Enemy < Window_Base
def initialize
super(0, 0, 480, 480)
self.contents = Bitmap.new(width - 32, height - 32)
refresh
end
def refresh
self.contents.clear
@data = []
(1...$data_enemies.size).each do |i|
if $game_system.defeated_enemy_number(i) > 0
@data.push($data_enemies[i])
end
end
self.contents.font.size = 36
@data.each do |enemy|
x = 4 + i % 2 * 240
y = i / 2 * 100
bitmap = RPG::Cache.batter(enemy.battler_name, enemy.battler_hue)
self.contents.blt(x, y, bitmap, Rect.new(0,0,100,100))
self.contents.draw_text(x + 104, y, 100, 100, "×" + $game_system.defeated_enemy_number(enemy.id).to_s, 2)
end
end
end
欢迎光临 Project1 (https://rpg.blue/) |
Powered by Discuz! X3.1 |