Project1
标题:
这个图标战斗的问题
[打印本页]
作者:
zxc3824
时间:
2011-7-31 18:17
标题:
这个图标战斗的问题
本帖最后由 zxc3824 于 2011-8-3 13:30 编辑
我下的是仙三系统,把里面的那个图标战斗拿了出来,原问题已经自己解决,但是新问题出来了,首先是他无论应用在哪个工程中,再没有开始选择战斗命令前,就出现一个命令选项框一闪而过,才开始进行战斗。原问题修改后的工程已经上传,希望大家能够帮帮新手。
#==========================================================================
# 本脚本来自www.66RPG.com,使用和转载请保留此信息
#==========================================================================
module Momo_IconCommand
# 图标名称设定
ATTACK_ICON_NAME = "击-1" # 攻撃
SKILL_ICON_NAME = "术-1" # 特技
SKILL2_ICON_NAME = "术-1" # 特技
GUARD_ICON_NAME = "防-1" # 防御
ITEM_ICON_NAME = "物-1" # 物品
ESCAPE_ICON_NAME = "逃-1" # 逃跑
BEIJING_ICON_NAME = "big"
# X坐标修正
X_PLUS = -40
# Y坐标修正
Y_PLUS = -80
# 选择时图标的动作
# 0:静止 1:放大
SELECT_TYPE = 0
# 闪烁时光芒的颜色
FLASH_COLOR = Color.new(255, 255, 255, 128)
# 闪烁时间
FLASH_DURATION = 10
# 闪烁间隔
FLASH_INTERVAL = 20
# 是否写出文字的名称
COM_NAME_DROW = false
# 文字名称是否移动
COM_NAME_MOVE = false
# 文字内容
ATTACK_NAME = "攻击" # 攻击
SKILL_NAME = "仙术" # 特技
GUARD_NAME = "防御" # 防御
ITEM_NAME = "物品" # 物品
ESCAPE_NAME = "逃跑" #逃跑
# 文字颜色
COM_NAME_COLOR = Color.new(255, 255, 255, 255)
# 文字坐标修正
COM_NAME_X_PLUS = 0
COM_NAME_Y_PLUS = 0
end
class Window_CommandIcon < Window_Selectable
attr_accessor :last_index
#------------------------------------------------------------------------
# ● オブジェクト初期化
#------------------------------------------------------------------------
def initialize(x, y, commands)
super(0, 240, 180,160)
# ウィンドウスキンに空文字列を指定してウィンドウを描画しないようにする
self.windowskin = nil#RPG::Cache.windowskin("5")
@item_max = commands.size
@commands = commands
@column_max = commands.size
@index = 0
#@column_max = 1
#@index_max = 0
@last_index = nil
@name_sprite = nil
@sprite = []
refresh
end
def dispose
super
for sprite in @sprite
sprite.dispose unless sprite.nil?
end
@name_sprite.dispose unless @name_sprite.nil?
end
#------------------------------------------------------------------------
# ● リフレッシュ
#------------------------------------------------------------------------
def refresh
@name_sprite.dispose unless @name_sprite.nil?
for sprite in @sprite
sprite.dispose unless sprite.nil?
end
@name_sprite = nil
draw_com_name if Momo_IconCommand::COM_NAME_DROW
@sprite = []
for i in 0...@item_max
draw_item(i)
end
end
#------------------------------------------------------------------------
# ● 項目の描画
#------------------------------------------------------------------------
def draw_item(index)
@sprite[index] = Sprite_Icon.new(nil, @commands[index])
@sprite[index].z = self.z + 1
end
def draw_com_name
@name_sprite = Sprite_Comm_Name.new(nil, get_com_name)
end
# 更新
def update
super
icon_update
com_name_update if Momo_IconCommand::COM_NAME_DROW
# 判断当前光标位置
self_update
if self.active
index_var = @index
tp_index = @index
mouse_x, mouse_y = Mouse.get_mouse_pos
mouse_not_in_rect = true
for i in 0..6
if i != 5
@index = i
@zzhaaa_1=1
update_cursor_rect
top_x = self.cursor_rect.x + self.x + 16
top_y = self.cursor_rect.y + self.y + 16
bottom_x = top_x + self.cursor_rect.width
bottom_y = top_y + self.cursor_rect.height
if (mouse_x > top_x) and (mouse_y > top_y) and
(mouse_x < bottom_x) and (mouse_y < bottom_y)
mouse_not_in_rect = false
if tp_index != @index
tp_index = @index
#if (@index != @oldindex)
$game_system.se_play($data_system.cursor_se)
#end
end
break
end
end
end
if mouse_not_in_rect
@zzhaaa_1=2
@index = index_var
if self.is_a?(Window_Target)
@index=-3
end
update_cursor_rect
Mouse.click_lock
else
Mouse.click_unlock
end
end
case @last_index
when 0 # 攻击
if Input.repeat?(Input::UP)
# 光标指向攻击
@index = 1
$game_system.se_play($data_system.cursor_se)
end
# 方向键右被按下的情况下
if Input.repeat?(Input::RIGHT)
# 光标指向仙术
@index = 6
$game_system.se_play($data_system.cursor_se)
end
# 方向键左被按下的情况下
if Input.repeat?(Input::LEFT)
# 光标指向法术
@index = 3
$game_system.se_play($data_system.cursor_se)
end
if Input.repeat?(Input::DOWN)
# 光标指向逃跑
#$game_system.se_play($data_system.cursor_se)
@index = 0
@index = 0
end
when 1 # 法术
# 方向键下被按下的情况下
if Input.repeat?(Input::DOWN)
# 光标指向逃跑
@index = 0
$game_system.se_play($data_system.cursor_se)
end
# 方向键右被按下的情况下
if Input.repeat?(Input::RIGHT)
# 光标指向仙术
@index = 6
$game_system.se_play($data_system.cursor_se)
end
# 方向键左被按下的情况下
if Input.repeat?(Input::LEFT)
# 光标指向物品
@index = 3
$game_system.se_play($data_system.cursor_se)
end
if Input.repeat?(Input::UP)
# 光标指向物品
@index = 1
@index = 1
end
when 2 # 防御
# 方向键上被按下的情况下
if Input.repeat?(Input::UP)
# 光标指向物品
@index = 3
$game_system.se_play($data_system.cursor_se)
end
# 方向键右被按下的情况下
if Input.repeat?(Input::RIGHT)
# 光标指向逃跑
@index = 4
$game_system.se_play($data_system.cursor_se)
end
if Input.repeat?(Input::DOWN)
# 光标指向防御
@index = 2
@index = 2
end
if Input.repeat?(Input::LEFT)
# 光标指向防御
@index = 2
end
# 方向键左被按下的情况下
when 3 # 物品
# 方向键下被按下的情况下
if Input.repeat?(Input::DOWN)
# 光标指向防御
@index = 2
$game_system.se_play($data_system.cursor_se)
end
# 方向键上被按下的情况下
if Input.repeat?(Input::UP)
# 光标指向攻击
@index = 1
$game_system.se_play($data_system.cursor_se)
end
# 方向键右被按下的情况下
if Input.repeat?(Input::RIGHT)
# 光标指向仙术
@index = 0
$game_system.se_play($data_system.cursor_se)
end
if Input.repeat?(Input::LEFT)
# 光标指向防御
@index = 3
@index = 3
end
# 方向键左被按下的情况下
when 4 # 逃跑
# 方向键上被按下的情况下
if Input.repeat?(Input::UP)
# 光标指向仙术
@index = 6
$game_system.se_play($data_system.cursor_se)
end
# 方向键左被按下的情况下
if Input.repeat?(Input::LEFT)
# 光标指向防御
@index = 2
$game_system.se_play($data_system.cursor_se)
end
if Input.repeat?(Input::DOWN)
# 光标指向防御
@index = 4
@index = 4
end
if Input.repeat?(Input::RIGHT)
# 光标指向仙术
@index = 4
@index = 4
end
when 6
if Input.repeat?(Input::UP)
# 光标指向仙术
@index = 1
$game_system.se_play($data_system.cursor_se)
end
if Input.repeat?(Input::LEFT)
# 光标指向防御
@index = 0
$game_system.se_play($data_system.cursor_se)
end
if Input.repeat?(Input::DOWN)
# 光标指向防御
@index = 4
$game_system.se_play($data_system.cursor_se)
end
if Input.repeat?(Input::RIGHT)
# 光标指向仙术
@index = 6
end
end
@last_index = self.index
end
# アイコンの更新
def icon_update
for i in
[email protected]
@sprite[i].active = (self.index == i)
@sprite[0].x = 87 #self.x + i * 24
@sprite[0].y = 325 #self.y + 0
@sprite[0].z = 9999
@sprite[1].x = 89
@sprite[1].y = 277#227
@sprite[1].z = 9999
@sprite[3].x = 42
@sprite[3].y = 310
@sprite[3].z = 9999
@sprite[4].x = 117
@sprite[4].y = 363
@sprite[4].z = 9999
@sprite[2].x = 59
@sprite[2].y = 363
@sprite[2].z = 9999
@sprite[6].x = 134
@sprite[6].y = 310
@sprite[6].z = 9999
@sprite[5].x = 88
@sprite[5].y = 320
@sprite[5].z = 9998
# @sprite[i].z = (self.index == i) ? self.z + 2 : self.z + 1
@sprite[i].visible = self.visible
@sprite[i].update
end
#修改…………………………
if @sprite[0].active
@sprite[0].icon_name = "击-2"
else
@sprite[0].icon_name = "击-1"
end
if @sprite[1].active
@sprite[1].icon_name = "术-2"
else
@sprite[1].icon_name = "术-1"
end
if @sprite[2].active
@sprite[2].icon_name = "防-2"
else
@sprite[2].icon_name = "防-1"
end
if @sprite[3].active
@sprite[3].icon_name = "物-2"
else
@sprite[3].icon_name = "物-1"
end
if @sprite[4].active
@sprite[4].icon_name = "逃-2"
else
@sprite[4].icon_name = "逃-1"
end
if @sprite[6].active
@sprite[6].icon_name = "技-2"
else
@sprite[6].icon_name = "技-1"
end
#修改…………………………
end
# コマンドネームの更新
def com_name_update
# if move_index?
@name_sprite.name = get_com_name
# end
@name_sprite.x = 80 #self.x - 12 + Momo_IconCommand::COM_NAME_X_PLUS
@name_sprite.y = 350 #self.y - 40 + Momo_IconCommand::COM_NAME_Y_PLUS
@name_sprite.z = 9998 #self.z + 1
@name_sprite.active = self.active
@name_sprite.visible = self.visible
@name_sprite.update
end
def get_com_name
make_name_set if @name_set.nil?
name = @name_set[self.index]
name = "" if name.nil?
return name
end
def make_name_set
@name_set = []
@name_set[0] = Momo_IconCommand::ATTACK_NAME
@name_set[1] = Momo_IconCommand::SKILL_NAME
@name_set[2] = Momo_IconCommand::GUARD_NAME
@name_set[3] = Momo_IconCommand::ITEM_NAME
@name_set[4] = Momo_IconCommand::ESCAPE_NAM
@name_set[5] = Momo_IconCommand::EBEIJING_NAM
end
def move_index?
return self.index != @last_index
end
def need_reset
@name_sprite.need_reset = true if Momo_IconCommand::COM_NAME_DROW
end
def update_cursor_rect
# 计算光标坐标
case @index
when 0
x=87-40
y=85-40
when 1
x=89-40
y=33-40
when 3
x=42-40
y=70-40
when 2
x=59-40
y=123-40
when 4
x=117-40
y=123-40
when 6
x=134-40
y=70-40
end
# 更新国标矩形
if (x != nil) and(y !=nil)
self.cursor_rect.set(x, y, 45, 45)
end
end
end
# アイコン用スプライト
class Sprite_Icon < Sprite
attr_accessor :active
attr_accessor :icon_name
#------------------------------------------------------------------------
# ● オブジェクト初期化
#------------------------------------------------------------------------
def initialize(viewport, icon_name)
super(viewport)
@icon_name = icon_name
@last_icon = @icon_name
@count = 0
self.bitmap = RPG::Cache.icon(@icon_name)
self.ox = self.bitmap.width / 2
self.oy = self.bitmap.height / 2
@active = false
end
#------------------------------------------------------------------------
# ● 解放
#------------------------------------------------------------------------
def dispose
if self.bitmap != nil
self.bitmap.dispose
end
super
end
#------------------------------------------------------------------------
# ● フレーム更新
#------------------------------------------------------------------------
def update
super
if @icon_name != @last_icon
@last_icon = @icon_name
self.bitmap = RPG::Cache.icon(@icon_name)
end
if @active
@count += 1
case Momo_IconCommand::SELECT_TYPE
when 0
icon_flash
when 1
icon_zoom
end
@count = 0 if @count == 20
else
icon_reset
end
end
def icon_flash
if @count % Momo_IconCommand::FLASH_INTERVAL == 0 or @count == 2
self.flash(Momo_IconCommand::FLASH_COLOR, Momo_IconCommand::FLASH_DURATION)
end
end
def icon_zoom
case @count
when 1..10
zoom = 1.0 + @count / 10.0
when 11..20
zoom = 2.0 - (@count - 10) / 10.0
end
self.zoom_x = zoom
self.zoom_y = zoom
end
def icon_reset
@count = 0
self.zoom_x = 1.0
self.zoom_y = 1.0
end
end
# コマンドネーム用スプライト
class Sprite_Comm_Name < Sprite
attr_accessor :active
attr_accessor :name
attr_accessor :need_reset
#------------------------------------------------------------------------
# ● オブジェクト初期化
#------------------------------------------------------------------------
def initialize(viewport, name)
super(viewport)
@name = name
@last_name = nil
@count = 0
@x_plus = 0
@opa_plus = 0
@need_reset = false
@active = false
self.bitmap = Bitmap.new(160, 32)
end
#------------------------------------------------------------------------
# ● 解放
#------------------------------------------------------------------------
def dispose
if self.bitmap != nil
self.bitmap.dispose
end
super
end
#------------------------------------------------------------------------
# ● フレーム更新
#------------------------------------------------------------------------
def update
super
if @active
if need_reset?
@need_reset = false
@last_name = @name
text_reset
end
move_text if Momo_IconCommand::COM_NAME_MOVE
end
end
def move_text
@count += 1
@x_plus = [@count * 8, 80].min
self.x = self.x - 80 + @x_plus
self.opacity = @count * 25
end
def text_reset
@count = 0
@x_plus = 0
self.bitmap.clear
self.bitmap.font.color = Momo_IconCommand::COM_NAME_COLOR
self.bitmap.draw_text(0, 0, 160, 32, @name)
end
def need_reset?
return (@name != @last_name or @need_reset)
end
end
class Scene_Battle
#------------------------------------------------------------------------
# ● プレバトルフェーズ開始
#------------------------------------------------------------------------
alias scene_battle_icon_command_start_phase1 start_phase1
def start_phase1
com1 = Momo_IconCommand::ATTACK_ICON_NAME
com2 = Momo_IconCommand::SKILL_ICON_NAME
com3 = Momo_IconCommand::GUARD_ICON_NAME
com4 = Momo_IconCommand::ITEM_ICON_NAME
com5 = Momo_IconCommand::ESCAPE_ICON_NAME
com6 = Momo_IconCommand::BEIJING_ICON_NAME
com7 = Momo_IconCommand::SKILL2_ICON_NAME
@actor_command_window = Window_CommandIcon.new(0, 0, [com1, com2, com3, com4, com5,com6,com7])
#@actor_command_window.y = 128
@actor_command_window.back_opacity = 255
@actor_command_window.active = false
@actor_command_window.visible = true
@actor_command_window.update
scene_battle_icon_command_start_phase1
end
#------------------------------------------------------------------------
# ● アクターコマンドウィンドウのセットアップ
#------------------------------------------------------------------------
alias scene_battle_icon_command_phase3_setup_command_window phase3_setup_command_window
def phase3_setup_command_window
scene_battle_icon_command_phase3_setup_command_window
# アクターコマンドウィンドウの位置を設定
#@actor_command_window.x = command_window_actor_x(@actor_index)
#@actor_command_window.y = command_window_actor_y(@actor_index)
@actor_command_window.need_reset
end
def command_window_actor_x(index)
$game_party.actors[index].screen_x + Momo_IconCommand::X_PLUS
end
def command_window_actor_y(index)
$game_party.actors[index].screen_y + Momo_IconCommand::Y_PLUS
end
end
#==========================================================================
# 本脚本来自www.66RPG.com,使用和转载请保留此信息
#==========================================================================
复制代码
求高手解决!!!
Project1.zip
(2.4 MB, 下载次数: 27)
2011-8-3 13:30 上传
点击文件名下载附件
dsu_plus_rewardpost_czw
作者:
寂静的夜里
时间:
2011-7-31 18:18
为什么不能应用在其他的工程?
将你原本下载的范例上传上来看看
作者:
xiezhen6805
时间:
2011-7-31 19:41
这个不需要什么高手解决,图标战斗需要用到你游戏文件夹里的图标,第7行ATTACK_ICON_NAME = "击-1" # 攻撃,这个“击-1”就是攻击图标的文件名,到原来仙三系统里把对应文件拷到你游戏文件夹中就行了。。
作者:
zxc3824
时间:
2011-7-31 20:11
xiezhen6805 发表于 2011-7-31 19:41
这个不需要什么高手解决,图标战斗需要用到你游戏文件夹里的图标,第7行ATTACK_ICON_NAME = "击-1" # 攻撃 ...
好吧,我把工程发上来给你们看看吧,加入了鼠标还有横版,好像必须要横版,这个战斗系统才管用,另外到了第二个角色的时候,就不能选择了。
Project1.zip
(1.74 MB, 下载次数: 26)
2011-7-31 20:11 上传
点击文件名下载附件
zxc3824于2011-8-1 18:39补充以下内容:
本来还希望你解决
zxc3824于2011-8-3 13:32补充以下内容:
原问题已经解决,现在时新问题
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1