Project1
标题:
鼠标系统
[打印本页]
作者:
淡/jk忘
时间:
2009-7-7 09:45
提示:
作者被禁止或删除 内容自动屏蔽
作者:
我不宅
时间:
2009-7-7 11:27
还是键盘吧!
作者:
藏剑江南
时间:
2009-7-8 21:15
我也想了解鼠标操作系统。。。但好像主站关于这方面的好像不多。。基本还是键盘流的。。。
作者:
redant
时间:
2009-7-8 21:47
本帖最后由 redant 于 2009-7-8 21:49 编辑
#==============================================================================
# 修改自redant
class Window_Picture_Command2 < Window_Selectable
attr_accessor :last_index
attr_accessor :active
attr_accessor :icon_name
#--------------------------------------------------------------------------
# ● 初始化对像
# width : 窗口的宽
# commands : 命令字符串序列
#--------------------------------------------------------------------------
def initialize(commands,type=2)
# 由命令的个数计算出窗口的高
super(0, 0, 640, 480)
@item_max = commands.size
@commands = commands
@name_sprite = nil
@dash = []
@sprite = []
@icon_name = icon_name
@last_icon = @icon_name
@count = 0
@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
@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_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
@sprite[index].z = 9998
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
for i in
[email protected]
@sprite[i].update
end
# @sprite[index].update
if $xiaoshi == true
@sprite[index].opacity = 0
end
if @sprite[index].index != self.index
@sprite[index].opacity = 155
else
@sprite[index].opacity = 255
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 and $stop == false
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
if $xiaoshi == true
else
Se.ok
end
@move_index = self.index
end
end
if $xiaoshi == true
@sprite[index].opacity = 0
else
if @sprite[index].index != self.index
@sprite[index].opacity = 240
else
@sprite[index].opacity = 255
end
end
end
end
elsif @type == 1
for index in @dash
if @sprite[index].index != self.index
@sprite[index].opacity = 155
else
@sprite[index].opacity = 255
end
end
end
end
#--------------------------------------------------------------------------
# ● 图片项目无效化
# index : 项目编号
#--------------------------------------------------------------------------
def disable_item(index)
@sprite[index].opacity = 155
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
alias window_picture_command_update update
def update
window_picture_command_update
update_item
icon_update
com_name_update
if @active
@count += 1
icon_flash
@count = 0 if @count == 20
else
@count = 0
end
if self.active
# 判断当前光标位置
case @last_index
when 0 # 攻击
# 方向键下被按下的情况下
if Input.repeat?(Input::DOWN)
# 光标指向物品
$game_system.se_play($data_system.cursor_se)
@index = 3
end
# 方向键上被按下的情况下
if Input.repeat?(Input::UP)
# 光标指向攻击
$game_system.se_play($data_system.cursor_se)
@index = 3
end
# 方向键右被按下的情况下
if Input.repeat?(Input::RIGHT)
# 光标指向防御
$game_system.se_play($data_system.cursor_se)
@index = 2
end
# 方向键左被按下的情况下
if Input.repeat?(Input::LEFT)
# 光标指向法术
$game_system.se_play($data_system.cursor_se)
@index = 1
end
when 1 # 法术
# 方向键下被按下的情况下
if Input.repeat?(Input::DOWN)
# 光标指向物品
$game_system.se_play($data_system.cursor_se)
@index = 3
end
# 方向键上被按下的情况下
if Input.repeat?(Input::UP)
# 光标指向攻击
$game_system.se_play($data_system.cursor_se)
@index = 0
end
# 方向键右被按下的情况下
if Input.repeat?(Input::RIGHT)
# 光标指向防御
$game_system.se_play($data_system.cursor_se)
@index = 2
end
# 方向键左被按下的情况下
if Input.repeat?(Input::LEFT)
# 光标指向法术
$game_system.se_play($data_system.cursor_se)
@index = 2
end
when 2 # 防御
# 方向键下被按下的情况下
if Input.repeat?(Input::DOWN)
# 光标指向物品
$game_system.se_play($data_system.cursor_se)
@index = 3
end
# 方向键上被按下的情况下
if Input.repeat?(Input::UP)
# 光标指向攻击
$game_system.se_play($data_system.cursor_se)
@index = 0
end
# 方向键右被按下的情况下
if Input.repeat?(Input::RIGHT)
# 光标指向防御
$game_system.se_play($data_system.cursor_se)
@index = 1
end
# 方向键左被按下的情况下
if Input.repeat?(Input::LEFT)
# 光标指向技能
$game_system.se_play($data_system.cursor_se)
@index = 1
end
when 3 # 物品
# 方向键下被按下的情况下
if Input.repeat?(Input::DOWN)
# 光标指向物品
$game_system.se_play($data_system.cursor_se)
@index = 0
end
# 方向键上被按下的情况下
if Input.repeat?(Input::UP)
# 光标指向攻击
$game_system.se_play($data_system.cursor_se)
@index = 0
end
# 方向键右被按下的情况下
if Input.repeat?(Input::RIGHT)
# 光标指向防御
$game_system.se_play($data_system.cursor_se)
@index = 2
end
# 方向键左被按下的情况下
if Input.repeat?(Input::LEFT)
# 光标指向法术
$game_system.se_play($data_system.cursor_se)
@index = 1
end
end
@last_index = self.index
end
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)
end
#######################
def draw_com_name
@name_sprite = Sprite_Comm_Name.new(nil, get_com_name)
end
####################
def icon_update
for i in
[email protected]
@sprite[i].update
end
end
def icon_flash
if @count % 20 == 0 or @count == 2
@sprite[index].flash(Color.new(255, 255, 255, 128), 10)
end
end
############
def text_reset
@count = 0
@x_plus = 0
self.bitmap.clear
src_rect = Rect.new(0, -5, 560, 128)
back_help = Bitmap.new("Graphics/system/menu/back/特技框.png")
self.bitmap.blt(0, -5, back_help, src_rect, 255)
#定义蓝色(很PL 不是吗?) Momo_IconCommand::COM_NAME_COLOR
self.bitmap.font.size = 16
#文字的大小
case @name
when "攻击"
self.bitmap.font.color = Color.new(255, 10, 10, 255)
when "特技"
self.bitmap.font.color = Color.new(255, 255, 0, 255)
when "物品"
self.bitmap.font.color = Color.new(5, 255, 0, 255)
when"防御"
self.bitmap.font.color = Color.new(5, 20, 255, 255)
end
self.bitmap.draw_text(25, 0, 260, 32, @name)
end
def com_name_update
# if move_index?
@name_sprite.name = get_com_name
if self.x<100#80
@name_sprite.x = self.x + 275
elsif self.x < 200#150
@name_sprite.x = self.x + 279
else self.x < 300#220
@name_sprite.x = self.x + 282
end
if self.y<200#190
@name_sprite.y = 145
elsif self.y < 300#250
@name_sprite.y = 210
else self.y < 400#320
@name_sprite.y= 295
end
# 文字出现的坐标 以固定在下面
#+ 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_NAME
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 need_reset?
return (@name != @last_name or @need_reset)
end
end
#==============================================================================
# ■ 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)
end
end
#==============================================================================
# ■ Sprite
#------------------------------------------------------------------------------
# ■ index 选择光标
#==============================================================================
class Sprite
attr_accessor :index
end
复制代码
不一定适合你 是我自己的
注意看开头 应该会用吧 比图标战斗还少点功能没实现
QQ截图未命名.jpg
(46.39 KB, 下载次数: 4)
下载附件
保存到相册
2009-7-8 21:49 上传
作者:
angelwangm
时间:
2009-7-8 21:59
谢谢蚂蚁,收下
作者:
阿强
时间:
2009-7-9 07:01
提示:
作者被禁止或删除 内容自动屏蔽
作者:
END66RPG
时间:
2009-7-9 09:53
不要
作者:
END66RPG
时间:
2009-7-9 09:53
啊啊啊
作者:
redant
时间:
2009-7-9 12:04
你仔细看下 你的那个脚本是不需要的了
直接复制过去
看看其实有些代码是一样的 = = 我就是拷过去的
作者:
风中承诺
时间:
2009-7-9 13:27
那个模式的确很好。
作者:
aq5888123
时间:
2009-7-10 12:54
看看
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1