赞 | 0 |
VIP | 2 |
好人卡 | 0 |
积分 | 16 |
经验 | 38341 |
最后登录 | 2024-5-15 |
在线时间 | 626 小时 |
Lv3.寻梦者
- 梦石
- 0
- 星屑
- 1556
- 在线时间
- 626 小时
- 注册时间
- 2010-8-5
- 帖子
- 451
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
本帖最后由 jiahui5592986 于 2012-8-6 15:15 编辑
- #==============================================================================
- # ■ Scene_Name
- #------------------------------------------------------------------------------
- # 处理名称输入画面的类。
- #==============================================================================
- class Scene_Shop
- #--------------------------------------------------------------------------
- # ● 主处理
- #--------------------------------------------------------------------------
- def main
- # 主处理
- shop_main
- # 执行过渡
- Graphics.transition
- # 主循环
- loop do
- # 刷新游戏画面
- Graphics.update
- # 刷新输入信息
- Input.update
- # 刷新信息
- shop_update
- # 如果画面切换就中断循环
- if $scene != self
- break
- end
- end
- # 准备过渡
- Graphics.freeze
- # 释放
- shop_dispose
- end
- #--------------------------------------------------------------------------
- # ● 商店主处理
- #--------------------------------------------------------------------------
- def shop_main
- # 生成商店窗口背景
- @skin5 = Sprite.new
- @skin5.bitmap = Bitmap.new("UI/商店")
- @skin5.x = 184
- @skin5.y = 30
- @skin5.z = 500
- shop = [[0,1],[0,2],[0,2],[0,2],[0,2],[0,2],[0,2],[0,2],[0,2],[0,2],
- [0,1],[0,2],[0,2],[0,2],[0,2]]
- # 生成窗口
- @shop_window = Window_ShopBuy.new($game_temp.shop_goods)
- @shop_window.z = 501
- @shop_window.help_window = Window_Help.new
- @shop_window.help_window.visible = false
- # 确定按钮
- @确定 = Sprite.new
- @确定.bitmap = Bitmap.new("UI/确定")
- @确定.x = 300
- @确定.y = 407
- @确定.z = 501
- 确定(0)
- # 叉按钮
- @叉7 = Sprite.new
- @叉7.bitmap = Bitmap.new("UI/叉")
- @叉7.x = 435
- @叉7.y = 35
- @叉7.z = 501
- 叉7(0)
- # 描绘物品
- draw_shop
- end
- #--------------------------------------------------------------------------
- # ● 刷新画面
- #--------------------------------------------------------------------------
- def shop_update
- # 获取鼠标位置
- @mouse_x, @mouse_y = Mouse.get_mouse_pos
- # 购买窗口刷新
- @shop_window.update
- # 刷新输入端口
- update_field
- # 按下 B 键的情况下
- if Input.trigger?(Input::X)
- # 演奏取消 SE
- $game_system.se_play($data_system.cancel_se)
- # 切换到菜单画面
- $scene = Scene_Menu.new(2)
- return
- end
- # 当按下鼠标左键时
- if Mouse.trigger?(Mouse::LEFT)
- # 光标存在的情况下
- if $help_visible
- # 同物品的情况下
- if @shop_window.select_index == @old_index
- @number += 1
- end
- # 释放输入窗口
- field_dispose
- # 描绘选中物品
- draw_shop
- return
- end
- # 生成输入窗口
- draw_field if @field.nil?
- end
- if @press2 == 1
- unless Mouse.press?(Mouse::LEFT)
- @press2 = 0
- # 确定
- if @mouse_x >= @确定.x and @mouse_x <= @确定.x + @确定.bitmap.width/3 and
- @mouse_y >= @确定.y and @mouse_y <= @确定.y + @确定.bitmap.height
- #######################################################
- return if $game_party.gold < @item.price*@number
- $game_party.gain_item(@item.id, @number)
- $scene = Scene_Map.new
- #######################################################
- return
- end
- # 叉
- if @mouse_x >= @叉7.x and @mouse_x <= @叉7.x + @叉7.bitmap.width/4 and
- @mouse_y >= @叉7.y and @mouse_y <= @叉7.y + @叉7.bitmap.height
- #######################################################
- $scene = Scene_Map.new
- #######################################################
- return
- end
- end
- end
- # 确定
- if @mouse_x >= @确定.x and @mouse_x <= @确定.x + @确定.bitmap.width/3 and
- @mouse_y >= @确定.y and @mouse_y <= @确定.y + @确定.bitmap.height
- 确定(1)
- if Mouse.press?(Mouse::LEFT)
- 确定(2)
- @press2 = 1
- end
- else
- 确定(0)
- end
- # 叉
- if @mouse_x >= @叉7.x and @mouse_x <= @叉7.x + @叉7.bitmap.width/4 and
- @mouse_y >= @叉7.y and @mouse_y <= @叉7.y + @叉7.bitmap.height
- 叉7(1)
- if Mouse.press?(Mouse::LEFT)
- 叉7(2)
- @press2 = 1
- end
- else
- 叉7(0)
- end
- end
- #--------------------------------------------------------------------------
- # ● 描绘选中物品
- #--------------------------------------------------------------------------
- def draw_shop
- @skin5.bitmap.dispose
- @skin5.bitmap = Bitmap.new("UI/商店")
- @skin5.bitmap.font = Font.new("宋体",14)
- @skin5.bitmap.font.color = Color.new(0,0,0,255)
- # 描绘金钱
- @skin5.bitmap.draw_text(126, 344, 100, 32, $game_party.gold.to_s, 0)
- if @shop_window.select_index >= 0
- # 获取物品
- @item = @shop_window.item
- @number = 1 if @shop_window.select_index != @old_index
- @old_index = @shop_window.select_index
- # 描绘物品单价
- @skin5.bitmap.draw_text(126, 272, 100, 32, @item.price.to_s, 0)
- # 描绘物品数量
- @skin5.bitmap.draw_text(126, 296, 100, 32, @number.to_s, 0) if @field.nil?
- # 描绘物品总额
- @skin5.bitmap.draw_text(126, 320, 100, 32, (@item.price*@number).to_s, 0)
- end
- end
- #--------------------------------------------------------------------------
- # ● 生成输入窗口
- #--------------------------------------------------------------------------
- def draw_field
- if @mouse_x >= 310 and @mouse_x <= 380 and @mouse_y >= 333 and @mouse_y <= 348
- if @shop_window.select_index >= 0 and @field.nil?
- # 生成输入窗口
- @viewport = Viewport.new(310,335,20,14)
- @field = Type_Field2.new(@viewport,false,false,true,Color.new(0,0,0,255),@number.to_s)
- @field.active = true
- draw_shop
- end
- return
- end
- field_dispose
- end
- #--------------------------------------------------------------------------
- # ● 刷新输入窗口
- #--------------------------------------------------------------------------
- def update_field
- # 刷新输入端口
- @field.update if @field != nil
- # 物品数量刷新
- if @field != nil
- if @field.get_text != [] and @field.get_text.to_s.to_i > 0
- @number = @field.get_text.to_s.to_i
- draw_shop
- return
- end
- @number = 1
- draw_shop
- end
- end
- #--------------------------------------------------------------------------
- # ● 释放输入窗口
- #--------------------------------------------------------------------------
- def field_dispose
- return if @field.nil?
- @field.dispose
- @viewport.dispose
- @field = nil
- draw_shop
- end
- #--------------------------------------------------------------------------
- # ● 刷新确定按钮
- #--------------------------------------------------------------------------
- def 确定(n)
- @确定.src_rect.set(@确定.bitmap.width/3*n, 0, @确定.bitmap.width/3, @确定.bitmap.height)
- end
- #--------------------------------------------------------------------------
- # ● 刷新叉按钮
- #--------------------------------------------------------------------------
- def 叉7(n)
- @叉7.src_rect.set(@叉7.bitmap.width/4*n, 0, @叉7.bitmap.width/4, @叉7.bitmap.height)
- end
- #--------------------------------------------------------------------------
- # ● 释放
- #--------------------------------------------------------------------------
- def shop_dispose
- field_dispose
- @确定.bitmap.dispose
- @确定.dispose
- @叉7.bitmap.dispose
- @叉7.dispose
- @shop_window.dispose
- @shop_window.help_window.dispose
- @skin5.bitmap.dispose
- @skin5.dispose
- end
- end
复制代码 这里是脚本,工程就不上传了.我相信大大们一眼就能看出来错误.
目前知道的BUG:1.购买物品后,银两没有减少.
2.购买物品后自动关闭商店窗口???
3.最好能附加个,银两颜色的脚本...
4.展示的商品说明都是最后一个商品的说明.或者你选中了某个商品后,其他的商品也变成了这个商品的说明.
能不能头透漏下:修改金钱上限在哪?... dsu_plus_rewardpost_czw |
|