Project1

标题: 跳跃问题 [打印本页]

作者: piaoy    时间: 2012-7-23 19:33
标题: 跳跃问题
  1.             last =  @direction_fix
  2.              @direction_fix = true
  3.              case self.direction
  4.               when 2
  5.                 self.jump(0,-1)
  6.               when 4
  7.                 self.jump(1,0)
  8.               when 6
  9.                 self.jump(-1,0)
  10.               when 8
  11.                 self.jump(0,1)               
  12.               end
  13.             @direction_fix = last
复制代码
为什么执行了这段脚本的character类实例会跳到屏幕边缘!!!!!急!!!dsu_plus_rewardpost_czw
作者: 七夕小雨    时间: 2012-7-23 19:38

莫不是你把这段脚本放入了update里面?

作者: piaoy    时间: 2012-7-23 20:24
绝对没有!而且跳是一次性的!不信你搞个空工程试试
作者: piaoy    时间: 2012-7-24 08:49
自己顶!不能沉
作者: 七夕小雨    时间: 2012-7-24 09:58
本帖最后由 七夕小雨 于 2012-7-24 12:26 编辑

范例传送门:http://115.com/file/e727i9zo

是这样嘛0 0,Orz,实在不知道LZ想要什么效果啊

我放在Game_Player(Game_Character的子类) 222行下面,= =跳跃过程中可以按上下左右改变要跳跃的方向
作者: hys111111    时间: 2012-7-24 11:21
  1.             last =  @direction_fix
  2.              @direction_fix = true
  3.              case self.direction
  4.               when 2
  5.                 self.jump(0,-1) if self.passable?(@x,@y-1) and !moving?
  6.               when 4
  7.                 self.jump(1,0) if self.passable?(@x+1,@y) and !moving?
  8.               when 6
  9.                 self.jump(-1,0) if self.passable?(@x-1,@y) and !moving?
  10.               when 8
  11.                 self.jump(0,1) if self.passable?(@x,@y+1) and !moving?
  12.               end
  13.             @direction_fix = last
复制代码
这样子试试看
作者: piaoy    时间: 2012-7-24 12:23
本帖最后由 piaoy 于 2012-7-24 12:23 编辑

回五楼:这段脚本应该是向后跳一步阿,怎么会跳一大步,跳到边缘了呢
作者: piaoy    时间: 2012-7-24 18:46
piaoy 发表于 2012-7-24 12:23
回五楼:这段脚本应该是向后跳一步阿,怎么会跳一大步,跳到边缘了呢

我。。。我看了,问题不一样,你问我是不是放到了update里,我是没有放的。按照你的范例写法,是一步一步跳过去,而我遇到的问题是瞬移过去的,我把问题范例发给你。 Project4.rar (186.71 KB, 下载次数: 108)


作者: Wind2010    时间: 2012-7-24 19:17
本帖最后由 Wind2010 于 2012-7-24 19:22 编辑

测试发现事件一直调用中,大概是这个问题- -
  1. class Game_Character
  2.   def test
  3.     return if self.jumping? or self.moving?
  4.     last =  @direction_fix
  5.     @direction_fix = true
  6.     case self.direction
  7.     when 2
  8.       self.jump(0,-1)
  9.     when 4
  10.       self.jump(1,0)
  11.     when 6
  12.       self.jump(-1,0)
  13.     when 8
  14.       self.jump(0,1)
  15.     end
  16.     @direction_fix = last
  17.   end
  18. end
复制代码

作者: piaoy    时间: 2012-7-24 19:47
Wind2010 发表于 2012-7-24 19:17
测试发现事件一直调用中,大概是这个问题- -

惨了。。。在空工程里是解决了,我的工程里这段脚本是嵌套在方法里的,这么写还是没有用
作者: piaoy    时间: 2012-7-24 19:49
piaoy 发表于 2012-7-24 19:47
惨了。。。在空工程里是解决了,我的工程里这段脚本是嵌套在方法里的,这么写还是没有用 ...

看错了,我再试试

作者: piaoy    时间: 2012-7-24 19:52
Wind2010 发表于 2012-7-24 19:17
测试发现事件一直调用中,大概是这个问题- -

认可答案按钮怎么没了。。。这个问题能讲一下原理吗?




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1