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

Project1

 找回密码
 注册会员
搜索

如何移动项目矩形的坐标

查看数: 1976 | 评论数: 2 | 收藏 0
关灯 | 提示:支持键盘翻页<-左 右->
    组图打开中,请稍候......
发布时间: 2018-2-12 17:13

正文摘要:

我想让窗口的项目每帧都移动2个坐标,产生滑动效果,但是直接在update方法中加上@rect.x += 2没反应,不过改成self.cursor_rect.x += 2也就是光指光标移动是可行的 如图: 。如果要连同内容这就是整个项目一起移动 ...

回复

张咚咚 发表于 2018-2-12 21:16:19

如果要循环的话就加个坐标超出判断在还原

  1. class Window_XXX < Window_Selectable
  2.   
  3.   def initialize
  4.     @s_index = -1
  5.     @deviation = Array.new(item_max, 0)
  6.     super(0, 0, 300, 96)
  7.     activate
  8.     select(0)
  9.     refresh
  10.   end
  11.   
  12.   def item_max
  13.     return 3
  14.   end

  15.   alias :old_update :update
  16.   def update
  17.     old_update
  18.     if @index != @s_index
  19.       @s_index = @index
  20.       @deviation = Array.new(item_max, 0)
  21.     end
  22.     @deviation[@index] += 2 ######
  23.     self.cursor_rect.x = @rect.x + @deviation[@index]
  24.     refresh
  25.   end

  26.   def draw_item(index)
  27.     @rect = item_rect(index)
  28.     @rect.x += @deviation[index]
  29.     draw_text(@rect, "XXXXX")
  30.   end

  31. end

  32. class Scene_Map < Scene_Base
  33.   
  34.   alias :old_create_all_windows :create_all_windows
  35.   def create_all_windows
  36.     old_create_all_windows
  37.     @xxx = Window_XXX.new
  38.   end
  39.   
  40. end
复制代码

点评

多谢大佬帮助,已经解决  发表于 2018-2-14 11:42
百里_飞柳 发表于 2018-2-12 17:28:49
……?
这些项目实际上是每次光标移动后整体重绘来的,所以……并没有想象中的单独的项目移动
可以试试每个项目变成新建一个精灵进行绘制(x)

点评

多谢老鹰大大,已经解决  发表于 2018-2-14 11:41
拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

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

GMT+8, 2025-9-15 14:23

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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