じ☆ve冰风 发表于 2026-8-3 07:56:48

KModTimer ACE

KModTimer ACE
Version 1.0.0

by Kyonides Arkanthes​

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 all the newly available script calls.

The Script

                Ruby:       
# * KModTimer ACE * #
#   Scripter : Kyonides Arkanthes
#   v1.0.0 - 2023-05-02

# * Script Calls * #

# - Reset Timer's Setup
# $game_timer.reset

# - Change Timer's X Alignment - Positions: :left, :center or :right
# $game_timer.pos_x = X-Alignment

# $game_timer.font_name = "Font Name"
# $game_timer.font_size = Number
# $game_timer.set_font("Font Name", Number)

# - Change the Font Color
# $game_timer.font_color(Red, Green, Blue)
# $game_timer.font_color(Red, Green, Blue, Alpha)

# - Change the Background Color
# $game_timer.bg_color(Red, Green, Blue)
# $game_timer.bg_color(Red, Green, Blue, Alpha)

# - Toggle Background Color - Boolean: true or false
# $game_timer.use_bg = Boolean

module KModTimer
# Initial Values
FONT_NAME = "Arial"
FONT_SIZE = 32
# Color Ranges (0..255)
FONT_COLOR =
BG_COLOR   =
USE_BG_COLOR = true
# Choose the Position: :left, :center or :right
POSITION_X = :left
# * End of Setup Section * #
extend self
attr_accessor :refresh
end

class Sprite_Timer
def create_bitmap
    self.bitmap = Bitmap.new(96, 48)
    bg_setup
    font_setup
end

def bg_setup
    @bg_color = Color.new(*$game_timer.bg_color)
end

def font_setup
    font = self.bitmap.font
    font.name = $game_timer.font_name
    font.size = $game_timer.font_size
    font.color.set(*$game_timer.font_color)
end

def redraw_backdrop
    bm = self.bitmap
    $game_timer.use_bg ? bm.fill_rect(bm.rect, @bg_color) : bm.clear
end

def redraw
    if KModTimer.refresh
      KModTimer.refresh = nil
      bg_setup
      font_setup
    end
    redraw_backdrop
    bitmap.draw_text(bitmap.rect, timer_text, 1)
end

def update_x
    case $game_timer.pos_x
    when :left
      self.x = 0
    when :center
      self.x = (Graphics.width - self.bitmap.width) / 2
    when :right
      self.x = Graphics.width - self.bitmap.width
    end
end

def update_position
    update_x
    self.y = 0
    self.z = 200
end
end

class Game_Timer
include KModTimer
alias :kyon_mod_timer_gm_sys_init :initialize
def initialize
    kyon_mod_timer_gm_sys_init
    reset
end

def reset
    @font_name = FONT_NAME.dup
    @font_size = FONT_SIZE
    @font_color = FONT_COLOR.dup
    @bg_color = BG_COLOR.dup
    @use_bg = USE_BG_COLOR
    @pos_x = POSITION_X
end

def set_font(new_name, new_size)
    KModTimer.refresh = true
    @font_name = new_name
    @font_size = new_size
end

def font_name=(new_name)
    KModTimer.refresh = true
    @font_name = new_name
end

def font_size=(new_size)
    KModTimer.refresh = true
    @font_size = new_size
end

def font_color(red, green, blue, alpha=255)
    KModTimer.refresh = true
    @font_color =
end

def bg_color(red, green, blue, alpha=255)
    KModTimer.refresh = true
    @bg_color =
end

def use_bg=(bool)
    KModTimer.refresh = true
    @use_bg = bool
end
attr_reader :font_name, :font_size, :font_color, :bg_color,:use_bg
attr_accessor :pos_x
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-ace.157106/
页: [1]
查看完整版本: KModTimer ACE