设为首页收藏本站同能贴吧 切换语言 繁体中文
开启辅助访问 切换到窄版
扫描二维码关注官方公众号
返回列表
+ 发新帖
查看: 85|回复: 0

[转载发布] KModTimer VX

[复制链接]
累计送礼:
0 个
累计收礼:
1 个
  • TA的每日心情
    开心
    前天 04:10
  • 签到天数: 209 天

    连续签到: 2 天

    [LV.7]常住居民III

    4446

    主题

    864

    回帖

    2万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

    VIP
    7
    卡币
    22899
    OK点
    16
    推广点
    0
    同能卷
    50
    积分
    28239

    灌水之王

    发表于 前天 10:35 | 显示全部楼层 |阅读模式
    KModTimer VX
    Version 1.0.0

    by Kyonides



    Introduction

    This is a simple scriptlet that provides some extra features for your timer sprite like custom font name and size and even a colored background. The last feature can be deactivated as well.

    The embedded comments include a list of the newly available script calls.

    The Script

                    Ruby:        
    1. # * KModTimer VX * #
    2. #   Scripter : Kyonides Arkanthes
    3. #   v1.0.0 - 2023-05-02
    4. # * Script Calls * #
    5. # - Reset Timer's Setup
    6. # $game_system.reset_timer
    7. # - Change Timer's X Alignment - Positions: :left, :center or :right
    8. # $game_system.timer_pos_x = X-Alignment
    9. # $game_system.timer_font_name = "Font Name"
    10. # $game_system.timer_font_size = Number
    11. # $game_system.timer_font("Font Name", Number)
    12. # - Change the Font Color
    13. # $game_system.timer_font_color(Red, Green, Blue)
    14. # $game_system.timer_font_color(Red, Green, Blue, Alpha)
    15. # - Change the Background Color
    16. # $game_system.timer_bg_color(Red, Green, Blue)
    17. # $game_system.timer_bg_color(Red, Green, Blue, Alpha)
    18. # - Toggle Background Color - Boolean: true or false
    19. # $game_system.timer_use_bg = Boolean
    20. module KModTimer
    21.   # Initial Values
    22.   FONT_NAME = "Arial"
    23.   FONT_SIZE = 32
    24.   # Color Ranges (0..255) [Red, Green, Blue, Alpha]
    25.   FONT_COLOR = [255, 255, 255, 255]
    26.   BG_COLOR   = [0, 0, 0, 80]
    27.   USE_BG_COLOR = true
    28.   # Choose the Position: :left, :center or :right
    29.   POSITION_X = :left
    30. # * End of Setup Section * #
    31.   extend self
    32.   attr_accessor :refresh
    33.   class TimerData
    34.     def initialize() reset_settings end
    35.     def reset_settings
    36.       @font_name = FONT_NAME.dup
    37.       @font_size = FONT_SIZE
    38.       @font_color = FONT_COLOR.dup
    39.       @bg_color = BG_COLOR.dup
    40.       @use_bg = USE_BG_COLOR
    41.       @pos_x = POSITION_X
    42.     end
    43.     attr_accessor :font_name, :font_size, :font_color
    44.     attr_accessor :bg_color, :use_bg, :pos_x
    45.   end
    46. end
    47. class Sprite_Timer
    48.   def initialize(viewport)
    49.     super(viewport)
    50.     @data = $game_system.timer_setup
    51.     self.bitmap = Bitmap.new(88, 48)
    52.     bg_setup
    53.     font_setup
    54.     update_position
    55.     self.y = 0
    56.     self.z = 500
    57.     update
    58.   end
    59.   def bg_setup
    60.     @bg_color = Color.new(*@data.bg_color)
    61.   end
    62.   def font_setup
    63.     font = self.bitmap.font
    64.     font.name = @data.font_name
    65.     font.size = @data.font_size
    66.     font.color.set(*@data.font_color)
    67.   end
    68.   def update_x
    69.     case @data.pos_x
    70.     when :left
    71.       self.x = 0
    72.     when :center
    73.       self.x = (Graphics.width - self.bitmap.width) / 2
    74.     when :right
    75.       self.x = Graphics.width - self.bitmap.width
    76.     end
    77.   end
    78.   def update_position
    79.     update_x
    80.     self.y = 0
    81.     self.z = 200
    82.   end
    83.   def redraw_backdrop
    84.     bm = self.bitmap
    85.     @data.use_bg ? bm.fill_rect(bm.rect, @bg_color) : bm.clear
    86.   end
    87.   def timer_text
    88.     min = @total_sec / 60
    89.     sec = @total_sec % 60
    90.     sprintf("%02d:%02d", min, sec)
    91.   end
    92.   def redraw
    93.     if KModTimer.refresh
    94.       KModTimer.refresh = nil
    95.       bg_setup
    96.       font_setup
    97.     end
    98.     redraw_backdrop
    99.     bm = self.bitmap
    100.     bm.draw_text(bm.rect, timer_text, 1)
    101.   end
    102.   def update_bitmap
    103.     if $game_system.timer / Graphics.frame_rate != @total_sec
    104.       @total_sec = $game_system.timer / Graphics.frame_rate
    105.       redraw
    106.     end
    107.   end
    108.   def update
    109.     super
    110.     self.visible = $game_system.timer_working
    111.     update_x
    112.     update_bitmap
    113.   end
    114. end
    115. class Game_System
    116.   alias :kyon_mod_timer_gm_sys_init :initialize
    117.   def initialize
    118.     kyon_mod_timer_gm_sys_init
    119.     @timer_setup = KModTimer::TimerData.new
    120.   end
    121.   def reset_timer
    122.     @timer_setup.reset_settings
    123.   end
    124.   def timer_pos_x=(new_x)
    125.     @timer_setup.pos_x = new_x
    126.   end
    127.   def timer_font(new_name, new_size)
    128.     KModTimer.refresh = true
    129.     @timer_setup.font_name = new_name
    130.     @timer_setup.font_size = new_size
    131.   end
    132.   def timer_font_name=(new_name)
    133.     KModTimer.refresh = true
    134.     @timer_setup.font_name = new_name
    135.   end
    136.   def timer_font_size=(new_size)
    137.     KModTimer.refresh = true
    138.     @timer_setup.font_size = new_size
    139.   end
    140.   def timer_font_color(red, green, blue, alpha=255)
    141.     KModTimer.refresh = true
    142.     @timer_setup.font_color = [red, green, blue, alpha]
    143.   end
    144.   def timer_bg_color(red, green, blue, alpha=255)
    145.     KModTimer.refresh = true
    146.     @timer_setup.bg_color = [red, green, blue, alpha]
    147.   end
    148.   def timer_use_bg=(bool)
    149.     KModTimer.refresh = true
    150.     @timer_setup.use_bg = bool
    151.   end
    152.   attr_reader :timer_setup
    153. end
    复制代码


    Terms & Conditions

    Feel free to use it.
    Optionally, you could include my nickname in your game credits.
    That's it.


    本贴来自国际rpgmaker官方论坛作者:kyonides处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/kmodtimer-vx.157110/
    天天去同能,天天有童年!
    回复 送礼论坛版权

    使用道具 举报

    文明发言,和谐互动
    文明发言,和谐互动
    高级模式
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    简体中文
    繁體中文
    English(英语)
    日本語(日语)
    Deutsch(德语)
    Русский язык(俄语)
    بالعربية(阿拉伯语)
    Türkçe(土耳其语)
    Português(葡萄牙语)
    ภาษาไทย(泰国语)
    한어(朝鲜语/韩语)
    Français(法语)
    关闭

    幸运抽奖

    社区每日抽奖来袭,快来试试你是欧皇还是非酋~

    立即查看

    聊天机器人
    Loading...

    QQ|Archiver|手机版|小黑屋|同能RPG制作大师 ( 沪ICP备12027754号-3 )

    GMT+8, 2026-7-14 14:21 , Processed in 0.065831 second(s), 55 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

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