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

Project1

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

[已经解决] 求角色不停前进的脚本

[复制链接]

Lv1.梦旅人

梦石
0
星屑
68
在线时间
208 小时
注册时间
2013-8-8
帖子
1296
跳转到指定楼层
1
发表于 2014-2-9 10:46:05 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 我在孤岛等你 于 2014-2-9 18:07 编辑

                                                                                           ↑      
要放在事件上用脚本进行,能调节速度,角色依然可以用←↓→调节方向。
我知道可以用事件做,但调不了方向与速度。
我已经没有兴趣认真做游戏了……只能胡扯

Lv1.梦旅人

薄凉看客

梦石
0
星屑
50
在线时间
1269 小时
注册时间
2010-6-20
帖子
1316
2
发表于 2014-2-9 11:59:52 | 只看该作者
就是这样了。。。。。。。。。。。。。。。

# 事件 脚本 输入 $game_temp.start_move = true 开始移动
# 事件 脚本 输入 $game_temp.move_turn = n 改变方向 0 上 1 下 2 左 3 右

# PS 一旦启用 将无视方向键!

class Game_Temp
  attr_accessor :start_move
  attr_accessor :move_turn
  alias initialize_move initialize
  def initialize
    initialize_move
    @start_move = false
    @move_turn = 0
  end
end
class Game_Player < Game_Character
  def update
    # 本地变量记录移动信息
    last_moving = moving?
    # 移动中、事件执行中、强制移动路线中、
    # 信息窗口一个也不显示的时候
    unless moving? or $game_system.map_interpreter.running? or
           @move_route_forcing or $game_temp.message_window_showing
      # 如果方向键被按下、主角就朝那个方向移动
      unless $game_temp.start_move
        case Input.dir4
        when 2
          move_down
        when 4
          move_left
        when 6
          move_right
        when 8
          move_up
        end
      end
      start_move
    end
    # 本地变量记忆坐标
    last_real_x = @real_x
    last_real_y = @real_y
    super
    # 角色向下移动、画面上的位置在中央下方的情况下
    if @real_y > last_real_y and @real_y - $game_map.display_y > CENTER_Y
      # 画面向下卷动
      $game_map.scroll_down(@real_y - last_real_y)
    end
    # 角色向左移动、画面上的位置在中央左方的情况下
    if @real_x < last_real_x and @real_x - $game_map.display_x < CENTER_X
      # 画面向左卷动
      $game_map.scroll_left(last_real_x - @real_x)
    end
    # 角色向右移动、画面上的位置在中央右方的情况下
    if @real_x > last_real_x and @real_x - $game_map.display_x > CENTER_X
      # 画面向右卷动
      $game_map.scroll_right(@real_x - last_real_x)
    end
    # 角色向上移动、画面上的位置在中央上方的情况下
    if @real_y < last_real_y and @real_y - $game_map.display_y < CENTER_Y
      # 画面向上卷动
      $game_map.scroll_up(last_real_y - @real_y)
    end
    # 不在移动中的情况下
    unless moving?
      # 上次主角移动中的情况
      if last_moving
        # 与同位置的事件接触就判定为事件启动
        result = check_event_trigger_here([1,2])
        # 没有可以启动的事件的情况下
        if result == false
          # 调试模式为 ON 并且按下 CTRL 键的情况下除外
          unless $DEBUG and Input.press?(Input::CTRL)
            # 遇敌计数下降
            if @encounter_count > 0
              @encounter_count -= 1
            end
          end
        end
      end
      # 按下 C 键的情况下
      if Input.trigger?(Input::C)
        # 判定为同位置以及正面的事件启动
        check_event_trigger_here([0])
        check_event_trigger_there([0,1,2])
      end
    end
  end
  def start_move
    if $game_temp.start_move
      case $game_temp.move_turn
      when 0 # 上
        move_up
      when 1 # 下
        move_down
      when 2 # 左
        move_left
      when 3 # 右
        move_right
      end
    end
  end
end

点评

事件 设置移动路线 那里可以改速度吧  发表于 2014-2-9 18:08
不能调速吗……  发表于 2014-2-9 18:06
no,控制导弹的游戏……玩家控制的导弹不停向前飞, 要避开障碍物,到达敌人基地…… 到达  发表于 2014-2-9 18:05
估计是滑冰吧。。  发表于 2014-2-9 12:20
贪吃蛇么?  发表于 2014-2-9 12:03

评分

参与人数 1星屑 +12 收起 理由
我在孤岛等你 + 12 认可答案

查看全部评分

回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-9-30 16:23

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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