设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 260|回复: 2
打印 上一主题 下一主题

[有事请教] 玩AI代码被AI整蒙了,求解

[复制链接]

Lv1.梦旅人

梦石
0
星屑
72
在线时间
5 小时
注册时间
2024-5-18
帖子
3
跳转到指定楼层
1
发表于 2025-2-23 11:24:31 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有帐号?注册会员

x
本人RUBY基础为零,找DS帮我写的代码,老是会78行报错,不知道为什么,大佬求解
# ★★★★★ 横向滚动物品栏 ★★★★★
class Window_HorizontalItem < Window_Selectable
  # 初始化
  def initialize
    super(0, 64, Graphics.width, Graphics.height - 64)
    @scroll_x = 0            # 滚动偏移量
    @scroll_speed = 20       # 每次滚动像素数
    self.index = 0
    refresh
  end

  # 每行显示数量
  def col_max
    5  # 修改数字可调整每行显示数量
  end

  # 动态计算窗口宽度
  def window_width
    Graphics.width
  end

  # 绘制单个物品
  def draw_item(index)
    return if index < 0
    item = @data[index]
    return unless item
   
    rect = item_rect(index)
    rect.x -= @scroll_x  # 应用横向滚动偏移
   
    # 绘制图标和名称
    draw_icon(item.icon_index, rect.x, rect.y)
    draw_text(rect.x + 24, rect.y, rect.width - 24, line_height, item.name)
  end

  # 处理横向滚动
  def update_scroll
    # 鼠标滚轮检测
    if Input.repeat?(Input::MOUSESCROLLUP)
      scroll_left
    elsif Input.repeat?(Input::MOUSESCROLLDOWN)
      scroll_right
    end

    # 键盘左右键检测
    if Input.repeat?(Input::LEFT)
      scroll_left
    elsif Input.repeat?(Input::RIGHT)
      scroll_right
    end
  end

  # 向左滚动
  def scroll_left
    @scroll_x = [@scroll_x - @scroll_speed, 0].max
    refresh
  end

  # 向右滚动
  def scroll_right
    max_scroll = [self.width - contents_width, 0].max
    @scroll_x = [@scroll_x + @scroll_speed, max_scroll].min
    refresh
  end

  # 优化刷新逻辑
  def refresh
    self.contents.dispose if self.contents
    self.contents = Bitmap.new(contents_width, contents_height)
    @data = $game_party.items
    @item_max = @data.size
    create_contents
    draw_all_items
  end
end

# ★★★★★ 修改菜单场景 ★★★★★
class Scene_Menu < Scene_Base
  alias horizontal_start start
  def start
    horizontal_start
    create_horizontal_window
  end

  def create_horizontal_window
    @item_window = Window_HorizontalItem.new
    @item_window.set_handler(:ok, method(:on_item_ok))
    @item_window.set_handler(:cancel, method(:return_scene))
  end

  # 每帧更新滚动
  def update
    super
    @item_window.update_scroll
  end

  # 资源释放
  def terminate
    super
    @item_window.dispose if @item_window
  end
end

Lv4.逐梦者

梦石
0
星屑
5779
在线时间
787 小时
注册时间
2019-1-20
帖子
202
2
发表于 2025-2-23 15:19:02 | 只看该作者
把 class Scene_Menu < Scene_Base 改成 class Scene_Menu < Scene_MenuBase

# 鼠标滚轮检测 那几行如果你没有相关脚本也要删除

以后这种问题还是发在相应版本的问题区吧?有些人不怎么逛水区 。

提高解答机会的方法:
看一下对应版本的帮助文件 看天气预报说今天不下雨
改变问题为更有可能的或常见的 如:天气自动变化下雨→天气系统 果然不准呀~
使用论坛的搜索功能查找相关问题 好丧啊... ...想看女装
清楚说明实际上你想解决的问题  想看坛友的女装  
脚本自己有改过的地方要标明  不要遮脸的
脚本有问题但不是默认的要全部贴出来 大胆点,尽情发
三包原则:包有BUG,包甩锅,包咕咕
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
43
在线时间
3 小时
注册时间
2025-2-16
帖子
5
3
发表于 2025-2-23 20:18:51 | 只看该作者
看不懂 AI写代码好用吗
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2025-3-31 10:45

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表