赞 | 12 |
VIP | 107 |
好人卡 | 6 |
积分 | 4 |
经验 | 31122 |
最后登录 | 2024-6-29 |
在线时间 | 1606 小时 |
Lv2.观梦者 傻♂逼
- 梦石
- 0
- 星屑
- 374
- 在线时间
- 1606 小时
- 注册时间
- 2007-3-13
- 帖子
- 6562
|
4楼
楼主 |
发表于 2008-5-31 02:26:23
|
只看该作者
号外~!!!号外!!!!从现在起赠送Mac外观一套,不限量供应。
欲下从速
http://rpg.blue/upload_program/files/Mac_92600706.png
核心脚本:
靠,没有注解
- =begin
- 感谢您使用本系统.
- 使用方法:
- 变量=Button.new
- 生成
- 变量.init(x,y,ev,text)#(ev的意思是触发后所执行的脚本)
- 设置
- 变量.update
- 刷新
- 变量.dispose
- 释放
- =end
- class Button
- def init(x,y,ev,text="出错了 text 没有内容"+ev.to_s)
- @x = x
- @y = y
- @click = false
- @seltime = 0
- @inli = false
- @ev = ev
- @text = text
- @button = []
- a = Bitmap.new(640,480)
- @button[0] = Sprite.new
- @button[0].x = @x+1
- @button[0].y = @y
- @button[0].bitmap = Bitmap.new("Graphics/Buttons/Macbutton(Noclick,Nomove)1")
- @n = 1
- for i in 1..((a.text_size(@text).width) / 32)+1
- @button.push(Sprite.new)
- @button[i].bitmap = Bitmap.new("Graphics/Buttons/Macbutton(Noclick,Nomove)2")
- @button[i].y = @y
- @button[i].x = @x+@button[0].bitmap.width+((i-1)*32)
- @n = @n+1
- end
- @button.push(Sprite.new)
- @button[@n].bitmap = Bitmap.new("Graphics/Buttons/Macbutton(Noclick,Nomove)3")
- @button[@n].y = @y
- @button[@n].x = @x+@button[0].bitmap.width+((@n-1)*32)
- @writetext = Sprite.new
- @writetext.x = @x+@button[0].bitmap.width+8
- @w = @x+@button[0].bitmap.width+((@n-1)*32) + @button[@n].bitmap.width
- @writetext.y = @y-8
- @writetext.bitmap = Bitmap.new(a.text_size(@text).width,64)
- @writetext.bitmap.font.color = Color.new(0,0,0)
- @writetext.bitmap.draw_text(1, 1, @w, 64, @text)
- a.dispose
- a = nil
- end
- #########################################################################
- #########################################################################
- #############################方法:updata#################################
- ########################用处:鼠标移动后处理#############################
- #########################################################################
- #########################################################################
- def update
- @mousex,@mousey = Mouse.pos
- if ((@mousex >= @x) and (@mousex <= @w))
- if ((@mousey >= @y) and (@mousey <= @y+48))
- if (@inli == false)
- # if
- for i in [email protected]
- @button[i].bitmap = Bitmap.new("Graphics/Buttons/Macbutton(Noclick,Hdmove)2")
- if i == 1
- @button[0].bitmap = Bitmap.new("Graphics/Buttons/Macbutton(Noclick,Hdmove)1")
- end
- if i == @button.size-1
- @button[@button.size-1].bitmap = Bitmap.new("Graphics/Buttons/Macbutton(Noclick,Hdmove)3")
- end
- @inli = true
- end
- end
- end
- end
- ######################
- if ((@mousex <= @x) or (@mousex >= @w)) or
- # p "x"
- ((@mousey <= @y) or (@mousey >= @y+48))
- #p "y"
- if (@inli)
- # if
- for i in [email protected]
- @button[i].bitmap = Bitmap.new("Graphics/Buttons/Macbutton(Noclick,Nomove)2")
- if i == 1
- @button[0].bitmap = Bitmap.new("Graphics/Buttons/Macbutton(Noclick,Nomove)1")
- end
- if i == @button.size-1
- @button[@button.size-1].bitmap = Bitmap.new("Graphics/Buttons/Macbutton(Noclick,Nomove)3")
- end
- @inli = false
- end
- end
- #end
- end
- ###############
- if @inli == true and Mouse.trigger?(0x01)
- for i in [email protected]
- @button[i].bitmap = Bitmap.new("Graphics/Buttons/Macbutton(Hdclick,Hdmove)2")
- if i == 1
- @button[0].bitmap = Bitmap.new("Graphics/Buttons/Macbutton(Hdclick,Hdmove)1")
- end
- if i == @button.size-1
- @button[@button.size-1].bitmap = Bitmap.new("Graphics/Buttons/Macbutton(Hdclick,Hdmove)3")
- end
- @inli = false
- end
- Graphics.update
- sleep(0.1)
- @click = true
- eval(@ev)
- end
- if @click
- @seltime = @seltime+1
- if @seltime >= 10
- @click = false
- @seltime = 0
- for i in [email protected]
- @button[i].bitmap = Bitmap.new("Graphics/Buttons/Macbutton(Noclick,Nomove)2")
- if i == 1
- @button[0].bitmap = Bitmap.new("Graphics/Buttons/Macbutton(Noclick,Nomove)1")
- end
- if i == @button.size-1
- @button[@button.size-1].bitmap = Bitmap.new("Graphics/Buttons/Macbutton(Noclick,Nomove)3")
- end
- # @inli = false
- end
- end
- end
- end
- def dispose
- @x = nil
- @y = nil
- @click = nil
- @seltime = nil
- @inli = nil
- @ev = nil
- @text = nil
- for i in [email protected]
- @button[i].bitmap.dispose
- @button[i].dispose
- Graphics.update
- end
- @mousex = nil
- @mousey = nil
- # self = nil
- end
- end
复制代码
再送一个使用范例:
class Scene_Button #定义一个 Scene_Button 类
def main #定义main方法
# 生成活动块
@spriteset = Spriteset_Map.new
# 生成按钮
@button = [] #arry
@button[0] = Button.new
@button[0].init(64,64,"print('你好')","单击后出现你好")
@button[1] = Button.new
@button[1].init(64,64+64,"print('再见')","单击后出现再见")
@button[2] = Button.new
@button[2].init(64,64+64+64,"$scene = Scene_Menu.new","召唤菜单")
@button[3] = Button.new
@button[3].init(64,64+64+64+64,"$scene = Scene_Map.new","返回地图")
########################################################
Graphics.transition
# 主循环
loop do
# 刷新游戏画面
Graphics.update
# 刷新输入信息
Input.update
# 刷新画面
for i in 0..3
@button.update
end
# 如果画面被切换的话就中断循环
if $scene != self
break
end
end
# 准备过渡
Graphics.freeze
# 释放窗口
for i in 0..3
@button.dispose
@button = nil
end
@button = nil
end
end |
|