- 累计送礼:
- 0 个
- 累计收礼:
- 0 个
TA的每日心情 | 开心 5 小时前 |
---|
签到天数: 114 天 连续签到: 4 天 [LV.6]常住居民II

管理员
  
- VIP
- 6
- 卡币
- 10622
- OK点
- 16
- 推广点
- 0
- 同能卷
- 0
- 积分
- 13391


|
使用方法:
该脚本是用图片做命令按钮,一般用于用图片代替菜单中的窗口命令钮,美化游戏。
使用起来比较简单,脚本会自动判断位置。
运动类型为两种:
注意,如果支持鼠标请配上鼠标脚本。
type = 1 只支持键盘
type = 2 支持键盘+鼠标
与调用一般命令窗口一样!
如:先设定一个命令按钮图片以及坐标
p1 = ["图片名",图片X坐标,图片Y坐标]
范例游戏里为
#################################################
s1 = ["图片名一",100,0]
s2 = ["图片名二",200,150]
s3 = ["图片名三",300,200]
@command_window = Window_Picture_Command.new([s1,s2,s3],type)
#################################################
这里的type的值就是刚才所支持的
type = 1 只支持键盘
type = 2 支持键盘+鼠标
#################################################
s1 = ["新游戏",100,0]
s2 = ["继续游戏",200,150]
s3 = ["离开游戏",300,200]
@command_window = Window_Picture_Command.new([s1,s2,s3],1/2)
#################################################
大概就这样了,不明白看范例游戏吧。
注意,如果支持鼠标请配上鼠标脚本。 先把脚本贴上 - #==============================================================================# ■ Window_Picture_Command#------------------------------------------------------------------------------=begin该脚本是用图片做命令按钮,使用起来比较简单,脚本会自动判断位置。使用方法:与调用一般命令窗口一样!type描绘类型type = 1 只支持键盘type = 2 支持键盘+鼠标如:先设定一个命令按钮图片以及坐标p1 = ["图片名",图片X坐标,图片Y坐标]范例游戏里为 ################################################# s1 = ["新游戏",100,0] s2 = ["继续游戏",200,150] s3 = ["离开游戏",300,200] @command_window = Window_Picture_Command.new([s1,s2,s3],type) ################################################# 这里的type的值就是刚才所支持的 type = 1 只支持键盘 type = 2 支持键盘+鼠标 ################################################# s1 = ["新游戏",100,0] s2 = ["继续游戏",200,150] s3 = ["离开游戏",300,200] @command_window = Window_Picture_Command.new([s1,s2,s3],2) ################################################# 大概就这样了,不明白看范例游戏吧。=end#==============================================================================class Window_Picture_Command < Window_Selectable #-------------------------------------------------------------------------- # ● 初始化对像 # width : 窗口的宽 # commands : 命令字符串序列 #-------------------------------------------------------------------------- def initialize(commands,type=1) # 由命令的个数计算出窗口的高 super(0, 0, 640, 480) @item_max = commands.size @commands = commands @dash = [] @sprite = [] @type = type @move_index = self.index self.opacity = 0 self.contents = Bitmap.new(width - 32, @item_max * 32) refresh self.index = 0 end #-------------------------------------------------------------------------- # ● 刷新 #-------------------------------------------------------------------------- def refresh self.contents.clear for i in 0...@item_max draw_picture_item(i, @type) end end #-------------------------------------------------------------------------- # ● 释放 #-------------------------------------------------------------------------- def dispose super for index in @dash if @sprite[index] != nil @sprite[index].dispose @sprite[index].bitmap.dispose end end end #-------------------------------------------------------------------------- # ● 描绘图片项目 # index : 项目编号 # type : 描绘类型 # type = 1 只支持键盘 # type = 2 双面支持 #-------------------------------------------------------------------------- def draw_picture_item(index, type) @sprite[index] = Sprite.new if @commands[index][0] == nil p "图片名设置有误" end if @commands[index][1] == nil p "图片X坐标设置有误" end if @commands[index][2] == nil p "图片Y坐标设置有误" end bitmap = RPG::Cache.picture(@commands[index][0]) @sprite[index].bitmap = bitmap @sprite[index].x = @commands[index][1] @sprite[index].y = @commands[index][2] @sprite[index].index = index if @sprite[index].index != self.index @sprite[index].color = Color.new(0,0,0,100) else @sprite[index].color = Color.new(0,0,0,0) end @dash.push(index) end #-------------------------------------------------------------------------- # ● 刷新图片项目 #-------------------------------------------------------------------------- def update_item if Mouse.get_mouse_pos != nil $mouse_x,$mouse_y = Mouse.get_mouse_pos end if @type == 2 for index in @dash if @sprite[index] != nil top_x = @sprite[index].x top_y = @sprite[index].y bottom_x = top_x + @sprite[index].bitmap.width bottom_y = top_y + @sprite[index].bitmap.height if ($mouse_x > top_x) and ($mouse_y > top_y) and ($mouse_x < bottom_x) and ($mouse_y < bottom_y) self.index = @sprite[index].index if @move_index != self.index Se.ok @move_index = self.index end end if @sprite[index].index != self.index @sprite[index].color = Color.new(0,0,0,100) else @sprite[index].color = Color.new(0,0,0,0) end end end elsif @type == 1 for index in @dash if @sprite[index].index != self.index @sprite[index].color = Color.new(0,0,0,100) else @sprite[index].color = Color.new(0,0,0,0) end end end end #-------------------------------------------------------------------------- # ● 图片项目无效化 # index : 项目编号 #-------------------------------------------------------------------------- def disable_item(index) @sprite[index].color = Color.new(0,0,0,100) end #-------------------------------------------------------------------------- # ● 刷新 #-------------------------------------------------------------------------- alias window_picture_command_update update def update window_picture_command_update update_item end #-------------------------------------------------------------------------- # ● 更新光标举行 #-------------------------------------------------------------------------- def update_cursor_rect if @index < 0 self.cursor_rect.empty return end row = @index / @column_max if row < self.top_row self.top_row = row end if row > self.top_row + (self.page_row_max - 1) self.top_row = row - (self.page_row_max - 1) end cursor_width = self.width / @column_max - 32 x = @index % @column_max * (cursor_width + 32) y = @index / @column_max * 32 - self.oy self.cursor_rect.set(x+5000, y, cursor_width, 32) endend#==============================================================================# ■ Se#------------------------------------------------------------------------------# ■ 音效模块#==============================================================================module Se def self.ok $game_system.se_play($data_system.cursor_se) end def self.no $game_system.se_play($data_system.cancel_se) endend#==============================================================================# ■ Sprite#------------------------------------------------------------------------------# ■ index 选择光标#==============================================================================class Sprite attr_accessor :indexend复制代码
复制代码
更新脚本:
修正了图片的显示问题
并增加了战斗图片菜单的范例。
其实用法都那样
就图片菜单的X,Y坐标和图片名3个属性拉!
新的范例:http://rpg.blue/upload_program/d ... ��钮_119885581.rar
范例图片有点难看自己换吧!
旧的范例:http://rpg.blue/upload_program/files/图片按钮_99496702.rar
本帖来自P1论坛作者★_茄孓,因Project1站服务器在国外有时候访问缓慢不方便作者交流学习,经联系P1站长fux2同意署名转载一起分享游戏制作经验,共同为国内独立游戏作者共同创造良好交流环境,原文地址: https://rpg.blue/forum.php?mod=viewthread&tid=99389 若有侵权,发帖作者可联系底部站长QQ在线咨询功能删除,谢谢。 |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?立即注册
x
|