赞 | 0 |
VIP | 0 |
好人卡 | 0 |
积分 | 1 |
经验 | 0 |
最后登录 | 2010-11-5 |
在线时间 | 0 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 1445
- 在线时间
- 0 小时
- 注册时间
- 2010-9-12
- 帖子
- 3
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
本帖最后由 ed2k 于 2010-9-21 13:38 编辑
如题所说,这只是为了练习(图片和窗口操作)而写的,所以就写了这个东西,应该没有bug。
这个系统我估计不会有人用的,这次纯粹是为了发一个研究样本,希望有人能对脚本的编写提供点建议。
打开图片后,方向键移动图片,q、w键缩放。
本脚本分三部分,以划分开
1.更改标题栏(无其他用)
2.旋转式选单(Scene类)
:完全可以挪作他用,估计可以用在标题画面
3。图片浏览系统(Scene类)
选单编写历程:
原来是写成平铺式的,不过因为原图片太大会重叠,所以就打算修改z坐标,选中那个那个就放前面。后来一想,干脆把另外两个缩小好了。
而因为修改update中z坐标的启发,就试了下x坐标随时间变动,于是就有了浮沉效果。
后来联想到其他游戏中的旋转式选单,于是就修改成现在这样子了
CG鉴赏系统.rar
(3.06 MB, 下载次数: 4515)
- #========================================================
- #增加选单
- #========================================================
- class Scene_Title < Scene_Base
- def create_command_window
- s1 = Vocab::new_game
- s2 = Vocab::continue
- s4 = Vocab::shutdown
- @command_window = Window_Command.new(172, [s1, s2, "CG鉴赏", s4])
- @command_window.x = (544 - @command_window.width) / 2
- @command_window.y = 288
- if @continue_enabled # 如果[读取存档]可用
- @command_window.index = 1 # 移动光标至该命令项目上
- else # 如果[读取存档]不可用
- @command_window.draw_item(1, false) # 半透明显示该命令项目
- end
- @command_window.openness = 0
- @command_window.open
- end
- def update
- super
- @command_window.update
- if Input.trigger?(Input::C)
- case @command_window.index
- when 0 # 新的剧情
- command_new_game
- when 1 # 读取存档
- command_continue
- when 2 #CG鉴赏
- command_Read_CG
- when 3 # 退出游戏
- command_shutdown
- end
- end
- end
- # ------------定义方法----------------
- def command_Read_CG
- Sound.play_decision
- close_command_window
- $scene = Scene_Read_CG.new
- end
- end
复制代码
- #===============================================
- # ** Scene_Read_CG
- #------------------------------------------------------------------------------
- # 这个类用来执行CG鉴赏的人物选择程式。
- #===============================================
- class Scene_Read_CG < Scene_Base
- #--------------------------------------------------------------------------
- # * 对象初始化
- # menu_index : 命令光标的起始位置
- #--------------------------------------------------------------------------
- def initialize(menu_index = 1)
- @menu_index = menu_index
- @card_size = 3 #项目数
- @card_name = ["灵梦", "蕾米", "阿求"] #项目名
- @card = []
- @gow_x = []
- @ji_shu_qi = 0
- @fu_hao = 1
- @temp_y = 0
- end
- #--------------------------------------------------------------------------
- # * 程式开始
- #--------------------------------------------------------------------------
- def start
- super
- create_menu_background
- refresh
- end
- #--------------------------------------------------------------------------
- # * 程式终止
- #--------------------------------------------------------------------------
- def terminate
- super
- dispose_menu_background
- @command_window.dispose
- @name_window.dispose
- for i in 0...@card_size
- @card[i].dispose
- end
- end
- #--------------------------------------------------------------------------
- # * 返回之前的画面
- #--------------------------------------------------------------------------
- def return_scene
- $scene = Scene_Title.new
- end
- #--------------------------------------------------------------------------
- # * 更新内容显示
- #--------------------------------------------------------------------------
- def refresh
- #-------------------窗口初始化------------------------------------
- @name_window = Window_Base.new(0, 0, 544, 416)
- @name_window.opacity = 0
- @command_window = Window_Command.new(544, @card_name, @card_size)
- @command_window.x = 0
- @command_window.y = 350
- @command_window.opacity = 0
- @command_window.contents_opacity = 0
- @command_window.index = @menu_index
- #-------------------图片初始化---------------------------------------
- for i in 0...@card_size
- @card[i] = Sprite.new
- @card[i].bitmap = Bitmap.new("Graphics/Pictures/card#{i}")#读取对应项目图片
- @card[i].ox = @card[i].bitmap.width / 2
- @card[i].oy = @card[i].bitmap.height / 2
- @gow_x[i]=544 / @card_size /2 * (2 * i + 1) #分配x
- @card[i].x = @gow_x[i]
- @card[i].y = 250
- @card[i].z = 100
- @card[i].zoom_x = 0.5
- @card[i].zoom_y = 0.5
- end
- #--------------------描绘选中项目名------------------------------
- @name_window.contents.draw_text(0, 270, 500, 50, @card_name[@command_window.index],1)
- end
- #--------------------------------------------------------------------------
- # * 更新帧
- #--------------------------------------------------------------------------
- def update
- super
- update_menu_background
- @name_window.update
- @command_window.update
- #----------------描绘动态图片效果--------------------------------
- @ji_shu_qi = @ji_shu_qi % 100 + 1
- if(@ji_shu_qi <= 49)
- @ji_shu_qi % 3 == 0 ? @fu_hao = 1 : @fu_hao = 0
- elsif(@ji_shu_qi > 53)
- @ji_shu_qi % 3 == 0 ? @fu_hao = -1 : @fu_hao = 0
- end
- for i in 0...@card_size
- pian_yi = (@card_size - @command_window.index + i +1) % @card_size #计算偏移量
- if(i == @command_window.index)
- @card[i].x = @gow_x[pian_yi]
- @temp_y += @fu_hao
- @card[i].y = 150 + @temp_y
- @card[i].zoom_x = 1
- @card[i].zoom_y = 1
- else
- @card[i].x = @gow_x[pian_yi]
- @card[i].y = 250
- @card[i].zoom_x = 0.5
- @card[i].zoom_y = 0.5
- end
- end
- #-----------------------update选中项目名称------------------------
- if Input.dir4 != 0
- @name_window.contents.clear
- @name_window.contents.draw_text(222, 270, 544, 50, @card_name[@command_window.index])
- end
- #----------------------按键判定---------------------------
- if Input.trigger?(Input::B)
- return_scene
- elsif Input.trigger?(Input::C)
- Sound.play_decision
- $scene = Scene_CG.new(@command_window.index)
- end
- end
- end
复制代码
- #===================================================
- # ** Scene_CG
- #------------------------------------------------------------------------------
- # 这个类用来执行CG鉴赏的程式。
- #===================================================
- class Scene_CG < Scene_Base
- #--------------------------------------------------------------------------
- # * 对象初始化
- # card_num : 命令光标的起始位置
- # @cg_num :各项目的图片数
- # @hang_shu :行数
- # @lie_shu :列数(每行的图片数)
- #--------------------------------------------------------------------------
- def initialize(card_num)
- @card_num = card_num
- @pic = []
- @switch_pic = true
- @hang_shu = 2
- @lie_shu = 4
- @cg_num = [8, 8, 8]
- $temp_height = 0
- end
- #--------------------------------------------------------------------------
- # * 程式开始
- #--------------------------------------------------------------------------
- def start
- super
- create_menu_background
- refresh
- end
- #--------------------------------------------------------------------------
- # * 程式终止
- #--------------------------------------------------------------------------
- def terminate
- super
- dispose_menu_background
- @command_window.dispose
- for i in 0...@hang_shu
- for j in 0...@lie_shu
- break if (@lie_shu * i + j) >= @cg_num[@card_num]
- @pic[@lie_shu * i + j].dispose
- end
- end
- end
- #--------------------------------------------------------------------------
- # * 返回之前的画面
- #--------------------------------------------------------------------------
- def return_scene
- $scene = Scene_Read_CG.new(@card_num)
- end
- #--------------------------------------------------------------------------
- # * 更新内容显示
- #--------------------------------------------------------------------------
- def refresh
- #-------------------------窗口初始化--------------------------
- @command_window = Window_CG.new(576,["", "", "", "", "", "", "", ""],@lie_shu,0,0)
- @command_window.x = -16
- @command_window.y = -16
- @command_window.height = 448
- @command_window.opacity = 0
- @command_window.index = 0
- #----------------------显示图片初始化-------------------------
- @picture = Sprite.new
- @picture.z = 500
- for i in 0...@hang_shu
- for j in 0...@lie_shu
- break if (@lie_shu * i + j) >= @cg_num[@card_num]
- @pic[@lie_shu * i + j] = Sprite.new
- @pic[@lie_shu * i + j].bitmap = Cache.load_bitmap("Graphics/Pictures/", "CG_#{@card_num}_#{@lie_shu * i + j}")
- @pic[@lie_shu * i + j].x = 544 / @lie_shu * j
- @pic[@lie_shu * i + j].y = 416 / @hang_shu * i
- @pic[@lie_shu * i + j].zoom_x = 0.3
- @pic[@lie_shu * i + j].zoom_y = 0.3
- end
- end
- $temp_height = @pic[@command_window.index].bitmap.height * 0.3
- end
- #--------------------------------------------------------------------------
- # * 更新帧
- #--------------------------------------------------------------------------
- def update
- super
- @command_window.update
- #----------------图片移动判定---------------------------------
- if Input.dir4 != 0
- $temp_height = @pic[@command_window.index].bitmap.height * 0.3
- if @switch_pic == false
- step_y = [0, 1, 2, 1, 0, 0, 0, -1 ,-2, -1]#移动阵列
- step_x = [0, -1, 0, 1, -2, 0, 2, -1, 0, 1]
- @picture.x += step_x[Input.dir8]
- @picture.y += step_y[Input.dir8]
- end
- #-----------------退出判定---------------------------------------
- elsif Input.trigger?(Input::B)
- if @switch_pic
- return_scene
- else
- dis_pic
- end
- #-------------------选中判定--------------------------
- elsif Input.trigger?(Input::C)
- Sound.play_decision
- if @switch_pic
- @command_window.active = false
- @switch_pic = false
- @picture.bitmap = Bitmap.new("Graphics/Pictures/CG_#{@card_num}_#{@command_window.index}")
- @picture.x = 0
- @picture.y = 0
- @picture.zoom_x =0.7
- @picture.zoom_y =0.7
- else
- dis_pic
- end
- #-------------------缩放判定------------------------
- elsif Input.trigger?(Input::L)#每次缩放 变动 0.1
- @picture.zoom_x +=0.1
- @picture.zoom_y +=0.1
- elsif Input.trigger?(Input::R)
- @picture.zoom_x -=0.1
- @picture.zoom_y -=0.1
- end
- end
- #----------------------关闭图片方法----------------------
- def dis_pic
- @picture.bitmap.dispose
- @switch_pic = true
- @command_window.active = true
- end
- end
- #=====================================================
- # ** Window_CG
- #------------------------------------------------------------------------------
- # 为修改光标高度而定义
- #======================================================
- class Window_CG < Window_Command
-
- def initialize(width, commands, column_max = 1, row_max = 0, spacing = 32)
- super(width, commands, column_max, row_max, spacing)
- end
- #--------------------------------------------------------------------------
- # * 更新光标绘制
- #--------------------------------------------------------------------------
- def item_rect(index)
- rect = Rect.new(0, 0, 0, 0)
- rect.width = (contents.width + @spacing) / @column_max - @spacing
- rect.height = $temp_height #修改处
- rect.x = index % @column_max * (rect.width + @spacing)
- rect.y = index / @column_max * 416 / 2 #除以行数
- return rect
- end
- end
复制代码 |
评分
-
查看全部评分
|