vx/ピクチャの上下反転

返信する
ショウスケ
記事: 4
登録日時: 2025年7月16日(水) 00:38

vx/ピクチャの上下反転

投稿記事 by ショウスケ »

下記ウィンドウスキン変更の件、皆様のおかげで解決致しました。ありがとうございます。

相変わらずVXですが、ピクチャを上下反転するスクリプトは
どの様に打ち込めばいいでしょうか?

begin
 ピクチャー拡張 ver 0.0.0.1
        by 半生
http://www.tktkgame.com/


ピクチャー表示機能を拡張します。
・Game_Picture.set_hook(pic_no, flag=true)
 pic_no番のピクチャーをマップ座標で表示するようにします。
・Game_Picture.reset_pos_ajust(pic_no=-1)
 pic_no番のピクチャーをスクリーン座標に戻す。
 引数を省略した場合は全ピクチャをスクリーン座標表示に戻す。
・Game_Picture.set_mirror(pic_no, flag)
 pic_no番のピクチャーを左右反転するかどうか指定する

ver 0.0.0.1 (2010/08/04)
 公開

=end
class Game_Picture
attr_accessor :hook
attr_accessor :mirror

# クラスメソッド
# pic_noのピクチャーのマップ座標フラグを設定する
def self.set_hook(pic_no, flag=true)
return if $game_temp.in_battle
if pic_no.between?(0,19)
$game_map.screen.pictures[pic_no].hook = flag
end
end

# pic_noのピクチャーのマップ座標フラグをリセットする
def self.reset_pos_ajust(pic_no=-1)
return if $game_temp.in_battle
if pic_no < 0
for i in 0...20
$game_map.screen.pictures.hook = false
end
elsif pic_no.between?(0,19)
$game_map.screen.pictures[pic_no].hook = false
end
end

# pic_noのピクチャーの左右反転フラグを設定する
def self.set_mirror(pic_no, flag=true)
if pic_no.between?(0,19)
if $game_temp.in_battle
$game_troop.screen.pictures[pic_no].mirror = flag
else
$game_map.screen.pictures[pic_no].mirror = flag
end
end
end

# インスタンスメソッド
alias :_hn_expic__initialize :initialize unless private_method_defined?(:_hn_expic__initialize)
def initialize(*args)
_hn_expic__initialize(*args)
@hook = false
@mirror = false
end

# 画面座標からマップ座標へ
def scr2map_xy(mx=@x, my=@y)
return if $game_temp.in_battle
@x = (mx - $game_map.adjust_x(0) / 8) % ($game_map.width * 32)
@y = (my - $game_map.adjust_y(0) / 8) % ($game_map.height * 32)
end
end

class Sprite_Picture
# 更新
# 左右反転処理を追加
alias :_hn_expic__update :update
def update
_hn_expic__update
if self.visible
# マップ固定判定
if @picture.hook and !$game_temp.in_battle
self.x = $game_map.adjust_x(@picture.x * 8) / 8
self.y = $game_map.adjust_y(@picture.y * 8) / 8
end
# 左右反転判定
self.mirror = (@picture.mirror == true)
end
end
end

以上のスクリプト追加により、左右反転は実装しています。
素材をダウンロードさせて頂いたサイト様も閉鎖しているのかエラーが出て連絡がつかなくて…
お手数ですが、再びご教示いただけますと幸いです。
返信する

“VX / Ace:スクリプト素材のリクエスト”に戻る