Cerca nel Forum
Showing results for tags 'KMS Cursor Animation'.
Trovato 1 risultato
-
Nome Script: KMS Cursor Animation Versione: N/D Autore/i: tomy, traduzione EN by Mr. Bubble Informazioni: Visualizza un cursore animato nelle finestre di selezione del menù. Istruzioni: Inserite lo script sotto Material e inserite questa immagine nella cartella Graphic/System: Script: #_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ #_/ ◆ Animated Cursor - KMS_CursorAnimation ◆ VX Ace ◆ #_/ ◇ Last update : 2012/01/22 (TOMY@Kamesoft) ◇ #_/ ◇ Website: http://ytomy.sakura.ne.jp/ ◇ #_/ ◇ Translated by Mr. Bubble ◇ #_/---------------------------------------------------------------------------- #_/ Displays an animated cursor for menu selection windows. #_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ # This script adds a cursor animation for selectable windows. The number # of frames a cursor animation graphic can have is unlimited as long as the # cursor graphic supports that many frames. #---------------------------------------------------------------------------- # Script Calls #---------------------------------------------------------------------------- # Script calls are used in "Script..." event commands located under Tab 3. # # show_cursor_animation # Shows the cursor animation if it is not visible already. # # hide_cursor_animation # Hides the cursor animation if it is visable. #---------------------------------------------------------------------------- # Conditional Branch Script Calls #---------------------------------------------------------------------------- # Conditional branch script calls are used in the "Script" box in Conditional # Branch event commands. # # cursor_animation_visible? # Returns true if the cursor is visble. Returns false if cursor is hidden #_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ #============================================================================== # ★ BEGIN Setting ★ #============================================================================== module KMS_CursorAnimation # * Default Cursor Visibility Setting # true : Show cursor animation by default (can be seen on title screen) # false : Hide cursor animation by default (only seen in a new/loaded game) DEFAULT_ANIMATION = true # * Cursor Animation File # Cursor graphics are placed in the "Graphics/System" folder in your project ANIMATION_FILE = "CursorAnimation" # * Cursor Frame Count # The number of frames in the cursor animation graphic. Cursor frame # counts are unlimited as long as the cursor graphic supports that # many frames. FRAME_COUNT = 12 # * Cursor Animation speed # Higher values make the cursor animation slower. ANIMATION_WAIT = 4 # * Cursor Opacity OPACITY = 224 # * Cursor Blending Type # 0 : Normal # 1 : Add # 2 : Sub BLEND_TYPE = 1 # * Cursor Base Position # 0 : Higher # 1 : Center # 2 : Lower BASE_POSITION = 0 # * Cursor Position Adjustment [x, y] POSITION_REV = [-4, 0] end #============================================================================== # ☆ END Setting ☆ #============================================================================== $kms_imported = {} if $kms_imported == nil $kms_imported["CursorAnimation"] = true # ***************************************************************************** #============================================================================== # □ KMS_Commands #============================================================================== module KMS_Commands module_function #-------------------------------------------------------------------------- # ○ カーソルアニメを表示 #-------------------------------------------------------------------------- def show_cursor_animation $game_system.cursor_animation_visible = true end #-------------------------------------------------------------------------- # ○ カーソルアニメを非表示 #-------------------------------------------------------------------------- def hide_cursor_animation $game_system.cursor_animation_visible = false end #-------------------------------------------------------------------------- # ○ カーソルアニメ表示状態の取得 #-------------------------------------------------------------------------- def cursor_animation_visible? return $game_system.cursor_animation_visible end end #============================================================================== # ■ Game_Interpreter #============================================================================== class Game_Interpreter # イベントコマンドから直接コマンドを叩けるようにする include KMS_Commands end #============================================================================== # ■ Window_Base #============================================================================== class Window_Base < Window #-------------------------------------------------------------------------- # ○ クラス変数 #-------------------------------------------------------------------------- @@__cursor_animation = nil # カーソルアニメ #-------------------------------------------------------------------------- # ● オブジェクト初期化 # x : ウィンドウの X 座標 # y : ウィンドウの Y 座標 # width : ウィンドウの幅 # height : ウィンドウの高さ #-------------------------------------------------------------------------- alias initialize_KMS_CursorAnimation initialize def initialize(x, y, width, height) initialize_KMS_CursorAnimation(x, y, width, height) @@__cursor_animation.add_window(self) end #-------------------------------------------------------------------------- # ● 解放 #-------------------------------------------------------------------------- unless method_defined?(:dispose_KMS_CursorAnimation) alias dispose_KMS_CursorAnimation dispose end def dispose @@__cursor_animation.remove_window(self) dispose_KMS_CursorAnimation end #-------------------------------------------------------------------------- # ○ カーソルアニメを生成 #-------------------------------------------------------------------------- def self.create_cursor_animation @@__cursor_animation = Cursor_Animation.new end #-------------------------------------------------------------------------- # ○ カーソルアニメを破棄 #-------------------------------------------------------------------------- def self.dispose_cursor_animation @@__cursor_animation.dispose end #-------------------------------------------------------------------------- # ○ カーソルアニメを表示 #-------------------------------------------------------------------------- def self.show_cursor_animation @@__cursor_animation.visible = true @@__cursor_animation.update end #-------------------------------------------------------------------------- # ○ カーソルアニメを隠す #-------------------------------------------------------------------------- def self.hide_cursor_animation @@__cursor_animation.visible = false @@__cursor_animation.update end #-------------------------------------------------------------------------- # ○ カーソルアニメを更新 #-------------------------------------------------------------------------- def self.update_cursor_animation @@__cursor_animation.update end end #============================================================================== # ■ Game_System #============================================================================== class Game_System #-------------------------------------------------------------------------- # ○ 公開インスタンス変数 #-------------------------------------------------------------------------- attr_writer :cursor_animation_visible #-------------------------------------------------------------------------- # ○ オブジェクト初期化 #-------------------------------------------------------------------------- alias initialize_KMS_CursorAnimation initialize def initialize initialize_KMS_CursorAnimation @cursor_animation_visible = KMS_CursorAnimation::DEFAULT_ANIMATION end #-------------------------------------------------------------------------- # ○ カーソルアニメ可否フラグを取得 #-------------------------------------------------------------------------- def cursor_animation_visible if @cursor_animation_visible.nil? @cursor_animation_visible = KMS_CursorAnimatin::DEFAULT_ANIMATION end return @cursor_animation_visible end end #============================================================================== # □ Sprite_CursorAnimation #------------------------------------------------------------------------------ # カーソルアニメーション用の処理を追加したスプライトのクラスです。 #============================================================================== class Sprite_CursorAnimation < Sprite #-------------------------------------------------------------------------- # ● オブジェクト初期化 # viewport : ビューポート #-------------------------------------------------------------------------- def initialize(viewport = nil) super(viewport) @duration = 0 @frame_count = 0 self.bitmap = Cache.system(KMS_CursorAnimation::ANIMATION_FILE) self.src_rect.width = bitmap.width / 8 self.src_rect.height = bitmap.height / ([KMS_CursorAnimation].max / 8 + 1) self.ox = src_rect.width / 2 self.oy = src_rect.height / 2 self.opacity = KMS_CursorAnimation::OPACITY self.blend_type = KMS_CursorAnimation::BLEND_TYPE end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update super return unless visible @frame_count += 1 return if @frame_count % KMS_CursorAnimation::ANIMATION_WAIT != 0 @frame_count = 0 @duration -= 1 if @duration < 0 @duration = KMS_CursorAnimation::FRAME_COUNT - 1 end update_animation end #-------------------------------------------------------------------------- # ○ アニメーションを更新 #-------------------------------------------------------------------------- def update_animation self.src_rect.x = src_rect.width * (@duration % 8) self.src_rect.y = src_rect.height * (@duration / 8) end end #============================================================================== # □ Cursor_Animation #------------------------------------------------------------------------------ # カーソル周りのアニメーションを扱うクラスです。 #============================================================================== class Cursor_Animation #-------------------------------------------------------------------------- # ○ 公開インスタンス変数 #-------------------------------------------------------------------------- attr_accessor :visible #-------------------------------------------------------------------------- # ○ オブジェクト初期化 #-------------------------------------------------------------------------- def initialize reset end #-------------------------------------------------------------------------- # ○ 破棄 #-------------------------------------------------------------------------- def dispose @target_sprite.dispose @viewport.dispose end #-------------------------------------------------------------------------- # ○ リセット #-------------------------------------------------------------------------- def reset @visible = false @viewport = Viewport.new(0, 0, 640, 480) @windows = [] @target_sprite = Sprite_CursorAnimation.new(@viewport) @active_window = nil @viewport.visible = false @viewport.z = 30000 end #-------------------------------------------------------------------------- # ○ ウィンドウ追加 #-------------------------------------------------------------------------- def add_window(*window) @windows |= window.find_all { |w| w.is_a?(Window_Selectable) || w.is_a?(Window_SaveFile) } @windows.flatten! end #-------------------------------------------------------------------------- # ○ ウィンドウ削除 #-------------------------------------------------------------------------- def remove_window(*window) @windows -= window end #-------------------------------------------------------------------------- # ○ フレーム更新 #-------------------------------------------------------------------------- def update @viewport.update @target_sprite.update # 座標調整 dest_x, dest_y = get_cursor_pos if @target_sprite.x != dest_x if (dest_x - @target_sprite.<img src='http://rpgmkr.net/forum/public/style_emoticons/<#EMO_DIR#>/sourirex.gif' class='bbc_emoticon' alt=':sriden' />.abs < 4 @target_sprite.x = dest_x else dist = (dest_x - @target_sprite.<img src='http://rpgmkr.net/forum/public/style_emoticons/<#EMO_DIR#>/sourirex.gif' class='bbc_emoticon' alt=':fache2' /> / 4 dist = (dist > 0 ? [dist, 4].max : [dist, -4].min) @target_sprite.x += dist end end if @target_sprite.y != dest_y if (dest_y - @target_sprite.y).abs < 4 @target_sprite.y = dest_y else dist = (dest_y - @target_sprite.y) / 4 dist = (dist > 0 ? [dist, 4].max : [dist, -4].min) @target_sprite.y += dist end end end #-------------------------------------------------------------------------- # ○ カーソル位置取得 # [x, y] の形で返す。 #-------------------------------------------------------------------------- def get_cursor_pos dx = dy = 0 # 可視状態のアクティブウィンドウを取得 unless window_active?(@active_window) @active_window = search_active_window end # アクティブウィンドウがなければ非表示 if @active_window.nil? || !KMS_Commands.cursor_animation_visible? @viewport.visible = false dx = Graphics.width / 2 dy = Graphics.height / 2 return [dx, dy] end @viewport.visible = @visible # カーソル位置を計算 rect = @active_window.cursor_rect dx = rect.x + 16 + KMS_CursorAnimation::POSITION_REV[0] dy = rect.y + 16 + KMS_CursorAnimation::POSITION_REV[1] vp = @active_window.viewport if vp != nil dx += vp.rect.x - vp.ox dy += vp.rect.y - vp.oy end dx += @active_window.x - @active_window.ox dy += @active_window.y - @active_window.oy case KMS_CursorAnimation::BASE_POSITION when 0 # 上 dy += @target_sprite.oy when 1 # 中央 dy += rect.height / 2 when 2 # 下 dy += rect.height - @target_sprite.oy end return [dx, dy] end #-------------------------------------------------------------------------- # ○ ウィンドウの可視・アクティブ状態判定 #-------------------------------------------------------------------------- def window_active?(window) return false if window.nil? return false if window.disposed? return false unless window.visible if window.is_a?(Window_Selectable) return window.active elsif window.is_a?(Window_SaveFile) return window.selected end return false end #-------------------------------------------------------------------------- # ○ アクティブウィンドウを探す #-------------------------------------------------------------------------- def search_active_window return @windows.find { |w| if !w.visible false elsif w.is_a?(Window_Selectable) w.active && w.index >= 0 elsif w.is_a?(Window_SaveFile) w.selected else false end } end end #============================================================================== # ■ Scene_Base #============================================================================== class Scene_Base #-------------------------------------------------------------------------- # ● 開始処理 #-------------------------------------------------------------------------- alias start_KMS_CursorAnimation start def start Window_Base.create_cursor_animation Window_Base.show_cursor_animation start_KMS_CursorAnimation end #-------------------------------------------------------------------------- # ● 終了前処理 #-------------------------------------------------------------------------- alias pre_terminate_KMS_CursorAnimation pre_terminate def pre_terminate Window_Base.dispose_cursor_animation pre_terminate_KMS_CursorAnimation end #-------------------------------------------------------------------------- # ● フレーム更新(基本) #-------------------------------------------------------------------------- alias update_basic_KMS_CursorAnimation update_basic def update_basic update_basic_KMS_CursorAnimation # カーソルアニメを更新 Window_Base.update_cursor_animation end end Incompatibilità: N/D Note dell'Autore: Termini e condizioni sul sito di tomy: http://ytomy.sakura.ne.jp/tkool/rpgtech/rules.html