複数の画像を1枚に合成して表示させたい(RGSS3)

ちゃもも
記事: 5
登録日時: 2020年10月08日(木) 15:19

複数の画像を1枚に合成して表示させたい(RGSS3)

投稿記事by ちゃもも » 2020年10月08日(木) 15:28

viewtopic.php?t=4031
こちらで解決済のリクエストなのですが、この案件の
拡張をできる方にお願いしたいです。

合成する画像のファイル名を、変数に格納した文字列からでも呼びだせるようにしたものが欲しいです。

例えば上案件のスクリプトで
”test” =["test1","test2","test3"]という処理をしたい場合に

$game_variables[1]="test1"
$game_variables[2]="test2"
$game_variables[3]="test3"

”test” =[$game_variables[1],$game_variables[2],$game_variables[3]]

あるいは
$game_variables[1]="test1","test2","test3"
”test” =[$game_variables[1]]

等の表記で変数次第で合成する画像の素材をいつでも変更できるような仕様の
ピクチャ合成は可能でしょうか?

TOMO
記事: 343
登録日時: 2015年11月16日(月) 20:12
連絡を取る:

Re: 複数の画像を1枚に合成して表示させたい(RGSS3)

投稿記事by TOMO » 2020年10月08日(木) 16:16

※エラーが出たようなので削除しました
最後に編集したユーザー TOMO on 2020年10月09日(金) 17:26 [ 編集 1 回目 ]
ちゃもも
記事: 5
登録日時: 2020年10月08日(木) 15:19

Re: 複数の画像を1枚に合成して表示させたい(RGSS3)

投稿記事by ちゃもも » 2020年10月08日(木) 16:21

あ、さっそくありがとうございます
後で試験してからもう一度報告しますので
取り急ぎご挨拶だけおいておきます
ちゃもも
記事: 5
登録日時: 2020年10月08日(木) 15:19

Re: 複数の画像を1枚に合成して表示させたい(RGSS3)

投稿記事by ちゃもも » 2020年10月09日(金) 10:43

試験してみました。
ファイル名を直接入力する従来の形では問題無く表示されました

変数の代入の場合、

”test1” =["\V[1]","\V[2]"]で

ゲーム中イベントスクリプトで
$game_variables[1] = "test2"
$game_variables[2] = "test3"
とし、

test1をピクチャ表示で試しましたところ

ファイルが見つかりません:
Graphics/Pictures/V[1]

というエラーがでました。
"\V[1]" という表記の関係上、\V[1]を変数1ではなく「\V[1]」という文字列として
RGSSが扱っているのでは?と思い

”test1” =[\V[1],\V[2]]]

としてみたところ起動時にエラーが出ました

こちらの使い方が間違っているのかもしれませんが
ひとまずのご報告です
ちゃもも
記事: 5
登録日時: 2020年10月08日(木) 15:19

Re: 複数の画像を1枚に合成して表示させたい(RGSS3)

投稿記事by ちゃもも » 2020年10月09日(金) 10:50

追記

↑の”test1” =[\V[1],\V[2]]]は
”test1” =[\V[1],\V[2]]です


Name = {
"test1" => [$test1,$test2],
}

とした場合エラーはなくゲームは起動しましたが、

ゲーム内で
$test1="test2"
$test2="test3"

test をピクチャ表示としたところ

スクリプト38行目でエラー
undefined method 'gsub!' for nil:NilClass

となりました
TOMO
記事: 343
登録日時: 2015年11月16日(月) 20:12
連絡を取る:

Re: 複数の画像を1枚に合成して表示させたい(RGSS3)

投稿記事by TOMO » 2020年10月09日(金) 17:33

コード: 全て選択

# ※使用方法
# 判定画像名の画像を使うと、自動で合成されていきます
#
#
# ※追加仕様
# 合成画像名が\V[n]で、変数ID:nに格納されている文字列に置換されます
# (判別画像名には使用できません)

module TOMO
  module BlendBitmap
    # 合成画像リスト
    # return ["合成画像名1", "合成画像名2", …],
    def self.name(key_name)
      case key_name
      when "test1" # 判定画像名
        return [$game_variables[1], $game_variables[2], $game_variables[3]]
      end
      return nil
    end
  end
end

class << Cache
  alias tomo_blend_bitmap_load_bitmap load_bitmap
  def load_bitmap(folder_name, filename, hue = 0)
    @cache ||= {}
    if !filename.empty? && TOMO::BlendBitmap.name(filename)
      blend_bitmap(folder_name, filename)
    else
      tomo_blend_bitmap_load_bitmap(folder_name, filename, hue)
    end
  end
 
  def blend_bitmap(folder_name, filename)
    path = folder_name + filename
    unless include?(path)
      @cache[path] = Bitmap.new(path)
      TOMO::BlendBitmap.name(filename).each do |name|
        src_bitmap = load_bitmap(folder_name, name)
        @cache[path].blt(0, 0, src_bitmap, src_bitmap.rect)
      end
    end
    @cache[path]
  end
end
仕様を変更しました

コード: 全て選択

when 判定画像名
return [合成画像名1, 合成画像名2, …]
のように追加していってください

今度は大丈夫……だといいなぁ
ちゃもも
記事: 5
登録日時: 2020年10月08日(木) 15:19

Re: 複数の画像を1枚に合成して表示させたい(RGSS3)

投稿記事by ちゃもも » 2020年10月09日(金) 18:07

こちらで問題なく
変数からの呼び出し、合成表示ができました

お手数をおかけしました
本当にありがとうございます

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