| 赞 | 274 |
| VIP | |
| 好人卡 | |
| 积分 | 496 |
| 经验 | |
| 最后登录 | 2024-6-21 |
| 在线时间 | 1919 小时 |
- 梦石
- 10
- 星屑
- 39550
- 在线时间
- 1919 小时
- 注册时间
- 2010-11-14
- 回帖
- 3214

|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有账号?注册会员
×
嗯,功能如题目所说,其他的不多说了,直接放图放脚本。
希望收脚本的客官能留个评论。
[pre lang="ruby"]##
# 跑步时长限制 by Calendar99
#
module CLD99
module DASH_TIME_LIMIT
# 跑步最长持续时间(单位:帧)
MAX_DASH_TIME = 90
# 显示体力
DISPLAY_TIME_LIMIT = true
# 体力较多时的颜色
COLOR1 = Color.new(0, 0, 255)
# 体力较少时的颜色
COLOR2 = Color.new(255, 0, 0)
end
end
class Game_Player
attr_reader :dash_time
alias initialize_for_dash_with_time_limit initialize
def initialize
initialize_for_dash_with_time_limit
@dash_time = CLD99::DASH_TIME_LIMIT::MAX_DASH_TIME
end
alias dash_without_time_limit dash?
def dash?
dash_without_time_limit && @dash_time > 0
end
alias update_for_dash_with_time_limit update
def update
update_for_dash_with_time_limit
if moving? && dash_without_time_limit
@dash_time = [@dash_time - 1, 0].max
else
@dash_time = [@dash_time + 1, CLD99::DASH_TIME_LIMIT::MAX_DASH_TIME].min
end
end
end
class Sprite_Character
alias update_for_dash_time update
def update
update_for_dash_time
return unless character.is_a?(Game_Player)
return unless CLD99::DASH_TIME_LIMIT::DISPLAY_TIME_LIMIT
if character.dash_time < CLD99::DASH_TIME_LIMIT::MAX_DASH_TIME
display_dash_time
else
hide_dash_time
end
end
def display_dash_time
if !@sprite_dash_time
@sprite_dash_time = Sprite.new
@sprite_dash_time.ox = 16
@sprite_dash_time.oy = 4
end
if !@sprite_dash_time.bitmap
@bmp_dash_time1 = Bitmap.new(32, 8)
@bmp_dash_time1.fill_rect(0, 0, 32, 8, CLD99::DASH_TIME_LIMIT::COLOR1)
@bmp_dash_time2 = Bitmap.new(32, 8)
@bmp_dash_time2.fill_rect(0, 0, 32, 8, CLD99::DASH_TIME_LIMIT::COLOR2)
end
@sprite_dash_time.x = self.x
@sprite_dash_time.y = self.y + 4
rate = character.dash_time / CLD99::DASH_TIME_LIMIT::MAX_DASH_TIME.to_f
@sprite_dash_time.bitmap = rate < 0.3 ? @bmp_dash_time2 : @bmp_dash_time1
@sprite_dash_time.src_rect.width = 32 * rate
@sprite_dash_time.visible = true
end
def hide_dash_time
return unless @sprite_dash_time
@sprite_dash_time.visible = false
end
alias dispose_for_dash_time dispose
def dispose
dispose_for_dash_time
@sprite_dash_time.dispose if @sprite_dash_time
@bmp_dash_time1.dispose if @bmp_dash_time1
@bmp_dash_time2.dispose if @bmp_dash_time2
end
end[/pre] |
评分
-
查看全部评分
|