赞 | 0 |
VIP | 0 |
好人卡 | -15 |
积分 | 1 |
经验 | -11825 |
最后登录 | 2017-3-17 |
在线时间 | 52 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 60
- 在线时间
- 52 小时
- 注册时间
- 2017-1-12
- 帖子
- 192
|
1:可以用图块把头上事件弄成不可通行
2:使用重力脚本
随便 重力脚本如下
- #encoding:utf-8
- #==============================================================================
- # ■ Game_CharacterBase
- #------------------------------------------------------------------------------
- # 管理地图人物的基本类。是所有地图人物类的共通父类。拥有坐标、图片等基本信息。
- #==============================================================================
- =begin
- Hello!大家好
- 我是 茄子
-
- 很久没有来6R了,现在看见新的编辑器出来不免心动了,又玩起来RMVA来!
- 鄙人历来喜欢动作类游戏,希望这个脚本能给大家一点好的用处!
- 这是一个简单的【跳跃+重力脚本】
- 使用方法很简单
- (1)
- 大家根据范例里的每个事件的设置看吧!
- (2)
- 修改角色跳跃高度 建议取值 1-5
- $game_player.g_height = 5 # 基本值为5 越低则越高
- (3)
- 让所有角色能发动跳跃请打开跳跃开关即可跳跃1次!
- 比如让主角跳跃1次
- $game_player.jump_start = true
- 比如让事件1号跳跃1次
- $game_map.events[1].jump_start = true
- 范例在Scene_Map中按下空格键即可让主角跳跃一次!
- if Input.trigger?(:C)
- $game_player.jump_start
- end
- 当然让事件跳跃只要在事件的【移动路线】里面的【脚本】使用jump_start
- 就可以让事件跳跃了!
- =end
- #==============================================================================
- class Game_CharacterBase
- #--------------------------------------------------------------------------
- # ● 全局开关
- #--------------------------------------------------------------------------
- $gravity_key = true
- #--------------------------------------------------------------------------
- # ● 定义实例变量
- #--------------------------------------------------------------------------
- attr_accessor :g_speed_down
- attr_accessor :g_speed_up
- attr_accessor :g_key
- attr_accessor :isDown
- attr_accessor :isUp
- attr_accessor :g_height
- attr_accessor :jump_key
- attr_accessor :jump_number
- attr_accessor :gravity_key
- attr_accessor :double_key
- #--------------------------------------------------------------------------
- # ● 初始化对象
- #--------------------------------------------------------------------------
- def initialize
- init_public_members
- init_private_members
- @g_speed_down = 0.098
- @g_speed_up = 0.5
- @g_height = 3 # 越低跳的越高
- @jump_number = 0
- @g_key = true
- @isDown = false
- @isUp = false
- @jump_key = false
- @gravity_key = true
- @double_key = false
- end
- #--------------------------------------------------------------------------
- # ● 总判断
- #--------------------------------------------------------------------------
- def start_can?
- # 如果行走图为空则无【跳跃重力】
- return false if @character_name == ""
- # 如果重力开关关闭则无【跳跃重力】
- return ($gravity_key == false or @gravity_key == false)
- end
- #--------------------------------------------------------------------------
- # ● 起跳
- #--------------------------------------------------------------------------
- def jump_start
- if jump_can?
- @g_speed_up = 0.5
- @jump_key = true
- @isDown = false
- @g_key = false
- @jump_number += 1
- return
- end
- end
- #--------------------------------------------------------------------------
- # ● 可否再跳
- #--------------------------------------------------------------------------
- def jump_can?
- if @double_key
- return @jump_number <= 1 # 1则为最高跳跃2次,可自行修改如4则可跳跃5次
- else
- return @jump_number <= 0
- end
- end
- #--------------------------------------------------------------------------
- # ● 更新画面
- #--------------------------------------------------------------------------
- def update
- update_animation
- update_gravity
- update_real_jump
- return update_jump if jumping?
- return update_move if moving?
- return update_stop
- end
- #--------------------------------------------------------------------------
- # ● 跳跃效果
- #--------------------------------------------------------------------------
- def update_real_jump
- # 如果重力开关关闭则重力失效
- if start_can?
- return
- end
- # 如果不在下落时
- if @jump_key == true && @isDown == false
- @g_key = false
- if passable?(@x, @real_y.floor, 8) and @y > 0
- if @g_speed_up > 0
- @g_speed_up -= @g_height*0.01
- @y -= @g_speed_up
- @real_y = @y
- else
- @jump_key = false
- @real_y = @real_y
- @y = @real_y
- @g_key = true
- end
- else
- @jump_key = false
- @real_y = @real_y
- @y = @real_y
- @g_key = true
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 重力效果
- #--------------------------------------------------------------------------
- def update_gravity
- # 如果重力开关关闭则重力失效
- if start_can?
- return
- end
- # 如果下落开关打开的话
- if @g_key == true
- if passable?(@real_x.round, @y, 2) and @y <= $game_map.height
- @g_speed_down += 0.01
- my = get_down_pos(@y)
- dt = my - @y
- if dt > @g_speed_down
- @y += @g_speed_down
- else
- @y += dt
- end
- @real_y = @y
- @isDown = true
- else
- @jump_number = 0
- @real_y = @real_y.floor
- @y = @real_y
- @g_speed_down = 0.098
- @isDown = false
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 取得上一个障碍点的
- #--------------------------------------------------------------------------
- def get_up_pos(sy)
- my = sy.floor
- while(true)
- if passable?(@x, my, 8) == false
- return my
- else
- my -= 1
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 取得下一个障碍点的
- #--------------------------------------------------------------------------
- def get_down_pos(sy)
- my = sy.floor
- while(true)
- if passable?(@x, my, 2) == false
- return my
- else
- my += 1
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 判定是否移动中
- #--------------------------------------------------------------------------
- def moving?
- if start_can?
- @real_x != @x
- else
- @real_x != @x || @real_y != @y
- end
- end
- #--------------------------------------------------------------------------
- # ● 径向移动
- # d : 方向(2,4,6,8)
- # turn_ok : 是否可以改变方向
- #--------------------------------------------------------------------------
- def move_straight(d, turn_ok = true)
- if start_can?
- if d == 2 or d == 8
- return
- end
- end
- @move_succeed = passable?(@x, @y, d)
- if @move_succeed
- set_direction(d)
- @x = $game_map.round_x_with_direction(@x, d)
- @y = $game_map.round_y_with_direction(@y, d)
- @real_x = $game_map.x_with_direction(@x, reverse_dir(d))
- @real_y = $game_map.y_with_direction(@y, reverse_dir(d))
- increase_steps
- elsif turn_ok
- set_direction(d)
- check_event_trigger_touch_front
- end
- end
- end
复制代码 |
|