Pomógł: 22 razy Dołączył: 27 Kwi 2010 Posty: 136 Skąd: że znowu
Wysłany: Sro 12 Paź, 2011 21:27
Ehh... Kursor
Witam. A więc mam taki skrypt:
Spoiler:
Kod:
#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_
#_/ ◆ Animated Menu Cursor - KGC_CursorAnimation ◆ VX ◆
#_/ ◇ Last Update: 2008/04/01 ◇
#_/ ◆ Translation by Mr. Anonymous ◆
#_/-----------------------------------------------------------------------------
#_/ Installation: Insert this script above main.
#_/=============================================================================
#_/ This script allows you to display an animated cursor on selectable menu
#_/ items.
#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_
module KGC
module CursorAnimation
# ◆ Cursor Switch ◆
# You may specify the in-game switch that enables/disables the cursor.
SWITCH_ID = 20
# ◆ Cursor Start Display ◆
# true : Cursor is persistant (from the title screen onwards)
# false : Cursor is only displayed when a switch is turned on (SWITCH_ID)
DEFAULT_ANIMATION = true
# ◆ Cursor Animation Image File ◆
# This defines the cursor file located in "Graphics/System".
ANIMATION_FILE = "CursorAnimation"
# ◆ Cursor Animation Frame Count ◆
# This defines the amount of cells the animation uses from the cursor file.
FRAME_COUNT = 12
# ◆ Cursor Animation Wait Time ◆
# This defines the amount of frames between switching animation cells.
# Larger number = slower animation
# Smaller number = faster animation
ANIMATION_WAIT = 3
# ◆ Cursor Opacity ◆
# Opacity/Translucency (Max = 255)
OPACITY = 224
# ◆ Cursor Animation Blending ◆
# Blending Type
# 0. Normal 1. Add 2. Subtract
BLEND_TYPE = 1
# ◆ Base Cursor Selection Position ◆
# 0..On 1..Center 2..Under
BASE_POSITION = 1
# ◆ Cursor Alightment [x, y] ◆
# This defines the position of the cursor.
POSITION_REV = [-4, 0]
end
end
# 座標調整
dest_x, dest_y = get_cursor_pos
if @target_sprite.x != dest_x
if (dest_x - @target_sprite.x).abs < 4
@target_sprite.x = dest_x
else
dist = (dest_x - @target_sprite.x) / 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 = 0
dy = 0
# アクティブウィンドウを取得
unless window_active?(@active_window)
@active_window = search_active_window
end
# アクティブウィンドウがなければ非表示
if @active_window == nil || !$game_switches[KGC::CursorAnimation::SWITCH_ID]
@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 + KGC::CursorAnimation::POSITION_REV[0]
dy = rect.y + 16 + KGC::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
dy += @active_window.y
case KGC::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?
if window.is_a?(Window_Selectable)
return true if window.active
elsif window.is_a?(Window_SaveFile)
return true if 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
Nie możesz pisać nowych tematów Nie możesz odpowiadać w tematach Nie możesz zmieniać swoich postów Nie możesz usuwać swoich postów Nie możesz głosować w ankietach Nie możesz załączać plików na tym forum Możesz ściągać załączniki na tym forum