设为首页收藏本站同能贴吧 切换语言 繁体中文
开启辅助访问 切换到窄版
扫描二维码关注官方公众号
返回列表
+ 发新帖
查看: 134|回复: 0

[转载发布] Simple Standing Picture Plugin

[复制链接]
累计送礼:
0 个
累计收礼:
1 个
  • TA的每日心情
    开心
    2026-7-12 04:10
  • 签到天数: 209 天

    连续签到: 2 天

    [LV.7]常住居民III

    9072

    主题

    864

    回帖

    6万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

    VIP
    7
    卡币
    58885
    OK点
    16
    推广点
    0
    同能卷
    50
    积分
    68851

    灌水之王

    发表于 2026-7-27 09:16:10 | 显示全部楼层 |阅读模式
    DRG_StandingPicture version 1.0
    DynamiteRed


    Introduction
    This is a specialized plugin for displaying a "Standing Picture" image of your player character on the side of the map screen.
    It is licensed under the GNU General Public License version 3.
    https://opensource.org/licenses/GPL-3.0

    Features

    • Simple and easy to use.
    • Supports any game window size.
    • Supports any standing picture image size.
    • Fade in/out animation, and moves from one side to the other so that the player character is not blocked from view.
    • Automatically hides when a map event is running.
    • Can be enabled/disabled/set at will with plugin commands.
    • Independent from the built in ShowPicture RPG Maker command. Uses sprites drawn onto the map layer.

    Screenshots







    How to Use

    • Place DRG_StandingPicture.js into your plugin folder.
    • Enable the plugin within the RPG Maker MV Editor Plugin Manager
    • Place your standing picture images in the pictures folder. Make sure the file names do not contain spaces and start with the file name prefix specified in the plugin properties. For example (using the default file prefix) "Standing_MainChar.png"
    • In an event, use the "StandingPicEnable" plugin command to enable the standing picture system.
    • In an event, use the "StandingPicSet" plugin command to set the image. Specify the file name without the prefix or file extension. For example, "StandingPicSet MainChar".

    Demo
    Demo project download.

    Script
    Filename: DRG_StandingPicture.js
                    Code:       
    1. /*:
    2. * NOTE: Standing Picture images must be in the img\pictures folder
    3. *
    4. * The code contained in this file is licensed under the GNU General Public License version 3.
    5. * https://opensource.org/licenses/GPL-3.0
    6. *
    7. * @plugindesc Displays a character "Standing Picture" image on one side of the map screen.
    8. * @author DynamiteRed
    9. *
    10. * @help Standing Picture plugin by DynamiteRed.
    11.         Version 1.0
    12.         ---------------------------------------
    13.         Standing Picture images must be in your img\pictures folder.
    14.         Make sure your file names start with the "File Name Prefix" plugin
    15.         option, and do not have any spaces or whitespace characters.
    16.         The image can be of any size. They are scaled automatically to fit
    17.         into the game window. This plugin does not use the standard RPG
    18.         maker ShowPicture command, but rather draws the sprite directly onto
    19.         the map screen, so it should be compatible with most plugins. If an
    20.         image file cannot be found, an error is printed to the development
    21.         console and the game will not crash. By default on a new game the
    22.         Standing Picture is disabled.
    23.         Plugin commands:
    24.         StandingPicEnable
    25.         - Enables (Shows) the Standing Picture
    26.         StandingPicDisable
    27.         - Disables (Hides) the Standing Picture
    28.         StandingPicToggle
    29.         - Toggles the visibility of the Standing Picture
    30.         StandingPicSet [Filename minus prefix]
    31.         - Sets the Standing Picture to the given filename. Make sure the image
    32.         file names do not have any spaces or other whitespace characters.
    33.         ---------------------------------------
    34. *
    35. * @param File Name Prefix
    36. * @desc Prefix string that is appended to the start of the file name before loading the image. Surround with quotes ("").
    37. * Default: "Standing_"
    38. * @default "Standing_"
    39. *
    40. * @param Fade Frames
    41. * @desc Number of frames it takes for the image to fade in/out.
    42. * Default: 15
    43. * @default 15
    44. *
    45. * @param Side Swap Distance
    46. * @desc Distance (in tiles) from the right side of the map where the image will swap sides if the character reaches it.
    47. * Default: 10
    48. * @default 10
    49. *
    50. * @param Hide On Event
    51. * @desc If true, the Standing Picture is hidden while an event is running.
    52. * Default: true
    53. * @default true
    54. *
    55. */
    56. var DRG = DRG || {};
    57. DRG.StandingPic = DRG.StandingPic || {};
    58. DRG.StandingPic.Parameters = PluginManager.parameters('DRG_StandingPicture');
    59. DRG.StandingPic.FilePrefix = JSON.parse(DRG.StandingPic.Parameters["File Name Prefix"]);
    60. DRG.StandingPic.FadeFrames = JSON.parse(DRG.StandingPic.Parameters["Fade Frames"]);
    61. DRG.StandingPic.SideSwapDistance = JSON.parse(DRG.StandingPic.Parameters["Side Swap Distance"]);
    62. DRG.StandingPic.HideOnEvent = JSON.parse(DRG.StandingPic.Parameters["Hide On Event"]);
    63. DRG.StandingPic.CurrentFile = null;
    64. DRG.StandingPic.FadeTime = 0.25;
    65. DRG.StandingPic.Left  = { targetOpacity: 0, sprite: null };
    66. DRG.StandingPic.Right = { targetOpacity: 0, sprite: null };
    67. DRG.StandingPic.SideShown = 1;
    68. (function() {
    69.     // Method aliases
    70.     DRG.StandingPic.GS_Init = Game_System.prototype.initialize;
    71.     DRG.StandingPic.Scene_Map_UpdateMain = Scene_Map.prototype.updateMain;
    72.     DRG.StandingPic.Sprite_Map_CreateLowerLayer = Spriteset_Map.prototype.createLowerLayer
    73.     DRG.StandingPic.executeMove = Game_Player.prototype.executeMove;
    74.     DRG.StandingPic.Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
    75.     // Game System Init Override
    76.     Game_System.prototype.initialize = function()
    77.     {
    78.         DRG.StandingPic.GS_Init.call(this);
    79.         this._DRG_StandingPic_CurrentImg = "";
    80.         this._DRG_StandingPic_Hide = true;
    81.     };
    82.     // Called every frame as long as the map screen is active
    83.     // Updates the fade opacity of the standing pic
    84.     Scene_Map.prototype.updateMain = function() {
    85.         DRG.StandingPic.Scene_Map_UpdateMain.call(this);
    86.         // Update standing picture fade
    87.         DRG.StandingPic.UpdateFade();
    88.     };
    89.     // Called when the player takes a step
    90.     // Updates which side the standing picture is displayed
    91.     Game_Player.prototype.executeMove = function(direction) {
    92.         DRG.StandingPic.executeMove.call(this, direction);
    93.         DRG.StandingPic.UpdateSide();
    94.     };
    95.     // Called each time the map screen object is recreated, which is extremely often for some reason.
    96.     // That doesn't seem very efficient, RPG Maker devs!
    97.     Spriteset_Map.prototype.createLowerLayer= function() {
    98.         DRG.StandingPic.Sprite_Map_CreateLowerLayer.call(this);
    99.         if (typeof $gameSystem._DRG_StandingPic_CurrentImg == 'undefined' || $gameSystem._DRG_StandingPic_CurrentImg == null)
    100.         {
    101.             $gameSystem._DRG_StandingPic_CurrentImg = "";
    102.         }
    103.         if (typeof $gameSystem._DRG_StandingPic_Hide == 'undefined' || $gameSystem._DRG_StandingPic_Hide == null)
    104.         {
    105.             $gameSystem._DRG_StandingPic_Hide = true;
    106.         }
    107.         this.createStandingPictureSprites();
    108.         DRG.StandingPic.UpdateImage();
    109.         DRG.StandingPic.UpdatePosition();
    110.         DRG.StandingPic.UpdateSide();
    111.         DRG.StandingPic.Left.opacity = 0;
    112.         DRG.StandingPic.Right.opacity = 0;
    113.         // Add standing pic sprites to map layer
    114.         this.addChild(DRG.StandingPic.Left.sprite);
    115.         this.addChild(DRG.StandingPic.Right.sprite);
    116.         console.log("Standing Picture Map Layer Created.");
    117.     };
    118.     // Creates the map layer sprite objects if they have not already
    119.     // been created.
    120.     Spriteset_Map.prototype.createStandingPictureSprites = function()
    121.     {
    122.         if (typeof DRG.StandingPic.Left.sprite == 'undefined' || DRG.StandingPic.Left.sprite == null)
    123.         {
    124.             DRG.StandingPic.Left.sprite = new Sprite();
    125.         }
    126.         if (typeof DRG.StandingPic.Right.sprite == 'undefined' || DRG.StandingPic.Right.sprite == null)
    127.         {
    128.             DRG.StandingPic.Right.sprite = new Sprite();
    129.         }
    130.     };
    131.     Game_Interpreter.prototype.pluginCommand = function(command, args) {
    132.         DRG.StandingPic.Game_Interpreter_pluginCommand.call(this, command, args);
    133.    
    134.         command = command.toLowerCase();
    135.         if (command === 'standingpicenable')
    136.         {
    137.             console.log("Plugin Cmd: " + command);
    138.             $gameSystem._DRG_StandingPic_Hide = false;
    139.         }
    140.         else if (command === 'standingpicdisable')
    141.         {
    142.             console.log("Plugin Cmd: " + command);
    143.             $gameSystem._DRG_StandingPic_Hide = true;
    144.         }
    145.         else if (command === 'standingpictoggle')
    146.         {
    147.             console.log("Plugin Cmd: " + command);
    148.             $gameSystem._DRG_StandingPic_Hide = !$gameSystem._DRG_StandingPic_Hide;
    149.         }
    150.         else if (command === 'standingpicset')
    151.         {
    152.             console.log("Plugin Cmd: " + command);
    153.             if (args.length > 0) {
    154.                 $gameSystem._DRG_StandingPic_CurrentImg = args[0];
    155.                 DRG.StandingPic.UpdateImage();
    156.             }
    157.         }
    158.     };
    159.     // Returns the full file name of the current Standing Picture
    160.     // including the file name prefix if the file exists. Otherwise
    161.     // returns null.
    162.     DRG.StandingPic.getFileName = function()
    163.     {
    164.         var picID = "";
    165.         var fileName;
    166.         if ($gameSystem._DRG_StandingPic_CurrentImg === "") {
    167.             console.log("Warning: No standing picture image is set.");
    168.             return null;
    169.         }
    170.         fileName = this.FilePrefix + $gameSystem._DRG_StandingPic_CurrentImg;
    171.         if (this.PictureExists(fileName)) {
    172.             return fileName;
    173.         }
    174.         else
    175.         {
    176.             console.log("Warning: Unable to load standing picture image (File not found): " + fileName);
    177.             return null;
    178.         }
    179.     };
    180.     // Updates the position of the left and right standing picture
    181.     // sprite objects on the map screen
    182.     DRG.StandingPic.UpdatePosition = function()
    183.     {
    184.         var leftSprite = this.Left.sprite;
    185.         var rightSprite = this.Right.sprite;
    186.         leftSprite.x = 0;
    187.         leftSprite.y = 0;
    188.         leftSprite.anchor.x = 0;
    189.         leftSprite.anchor.y = 0;
    190.         rightSprite.x = Graphics.width;
    191.         rightSprite.y = 0;
    192.         rightSprite.anchor.x = 1.0;
    193.         rightSprite.anchor.y = 0;
    194.     };
    195.     // Scales the standing picture image so that it is the same height as the
    196.     // game window
    197.     DRG.StandingPic.UpdateScale = function()
    198.     {
    199.         var leftSprite = this.Left.sprite;
    200.         var rightSprite = this.Right.sprite;
    201.         var bitmap = leftSprite.bitmap;
    202.         // Scale image if it is not the same height as the
    203.         // game window
    204.         if (bitmap.height != Graphics.height)
    205.         {
    206.             var scale = Graphics.height / bitmap.height;
    207.             var width = Math.round(bitmap.width * scale);
    208.             var height = Graphics.height;
    209.             // Create a new bitmap that is the preferred size, and blit the standing picture image
    210.             // onto it
    211.             var resizedBitmap = new Bitmap(width, height);
    212.             resizedBitmap.bltImage(bitmap, 0, 0, bitmap.width, bitmap.height, 0, 0, width, height);
    213.             // Update sprite object bitmap references
    214.             leftSprite.bitmap = resizedBitmap;
    215.             rightSprite.bitmap = resizedBitmap;
    216.             this.UpdatePosition();
    217.             console.log("Standing Picture Resized.");
    218.         }
    219.     };
    220.     // Checks the player position and enables the approprate
    221.     // standing picture side
    222.     DRG.StandingPic.UpdateSide = function()
    223.     {
    224.         var _playerX = $gamePlayer.x;
    225.         var _mapWidth = $gameMap.width();
    226.         var distFromRight = _mapWidth - _playerX;
    227.         if (distFromRight < this.SideSwapDistance)
    228.         {
    229.             this.Left.targetOpacity = 255;
    230.             this.Right.targetOpacity = 0;
    231.         }
    232.         else
    233.         {
    234.             this.Left.targetOpacity = 0;
    235.             this.Right.targetOpacity = 255;
    236.         }
    237.     };
    238.     // Updates the opacity of both standing pictures (left and right)
    239.     DRG.StandingPic.UpdateFade = function()
    240.     {
    241.         var leftSpriteObj = this.Left;
    242.         var rightSpriteObj = this.Right;
    243.         var fadeStep = this.GetFadeStep(); // Get opacity offset
    244.         // Fade out standing picture if hidden/event is running
    245.         if ($gameSystem._DRG_StandingPic_Hide || ($gameMap.isEventRunning() && DRG.StandingPic.HideOnEvent))
    246.         {
    247.             leftSpriteObj.sprite.opacity -= fadeStep;
    248.             rightSpriteObj.sprite.opacity -= fadeStep;
    249.             return;
    250.         }
    251.         // Update sprite fade
    252.         if (leftSpriteObj.sprite.opacity < leftSpriteObj.targetOpacity) {
    253.             leftSpriteObj.sprite.opacity += fadeStep;
    254.         }
    255.         else if (leftSpriteObj.sprite.opacity > leftSpriteObj.targetOpacity) {
    256.             leftSpriteObj.sprite.opacity -= fadeStep;
    257.         }
    258.         if (rightSpriteObj.sprite.opacity < rightSpriteObj.targetOpacity) {
    259.             rightSpriteObj.sprite.opacity += fadeStep;
    260.         }
    261.         else if (rightSpriteObj.sprite.opacity > rightSpriteObj.targetOpacity) {
    262.             rightSpriteObj.sprite.opacity -= fadeStep;
    263.         }
    264.     };
    265.     // Returns the opacity difference for one frame of fading
    266.     DRG.StandingPic.GetFadeStep = function()
    267.     {
    268.         return 255 / DRG.StandingPic.FadeFrames;
    269.     };
    270.     // Loads the standing picture image file and updates
    271.     // the map sprite objects
    272.     DRG.StandingPic.UpdateImage = function()
    273.     {
    274.         var standingPicFile = this.getFileName();
    275.         if (this.CurrentFile == standingPicFile) { return; }
    276.         if (standingPicFile != null) {
    277.             var bitmap = ImageManager.loadPicture(standingPicFile)
    278.             this.Left.sprite.bitmap = bitmap;
    279.             this.Right.sprite.bitmap = bitmap;
    280.             bitmap.addLoadListener(this._onBitmapLoad.bind(this));
    281.             this.CurrentFile = standingPicFile;
    282.             console.log("Standing Picture Updated: " + standingPicFile);
    283.         }
    284.         else {
    285.             this.Left.sprite.bitmap = null;
    286.             this.Right.sprite.bitmap = null;
    287.         }
    288.     };
    289.     // Callback for when the image finishes loading.
    290.     // This ensures the standing picture image is resized to the game window height
    291.     DRG.StandingPic._onBitmapLoad = function()
    292.     {
    293.         this.UpdateScale();
    294.     };
    295.     // Checks if the given picture file name is in the img/pictures folder
    296.     DRG.StandingPic.PictureExists = function(picture)
    297.     {
    298.         var fileName = picture + ".png";
    299.         var path = require('path');
    300.         var base = path.dirname(process.mainModule.filename);
    301.         path = path.join(base, 'img/pictures/') + fileName;
    302.         var fs = require('fs');
    303.         if (fs.existsSync(path))
    304.         {
    305.             return true;
    306.         }
    307.         else
    308.         {
    309.             return false;
    310.         }
    311.     };
    312. })()
    313. //=============================================================================
    314. // End of File
    315. //=============================================================================
    复制代码


    Credit and Thanks
    - Created by DynamiteRed


    本贴来自国际rpgmaker官方论坛作者:DynamiteRed处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/simple-standing-picture-plugin.87549/

    本帖子中包含更多资源

    您需要 登录 才可以下载或查看,没有账号?立即注册

    x
    天天去同能,天天有童年!
    回复 送礼论坛版权

    使用道具 举报

    文明发言,和谐互动
    文明发言,和谐互动
    高级模式
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    简体中文
    繁體中文
    English(英语)
    日本語(日语)
    Deutsch(德语)
    Русский язык(俄语)
    بالعربية(阿拉伯语)
    Türkçe(土耳其语)
    Português(葡萄牙语)
    ภาษาไทย(泰国语)
    한어(朝鲜语/韩语)
    Français(法语)
    关闭

    幸运抽奖

    社区每日抽奖来袭,快来试试你是欧皇还是非酋~

    立即查看

    聊天机器人
    Loading...

    QQ|Archiver|手机版|小黑屋|同能RPG制作大师 ( 沪ICP备12027754号-3 )

    GMT+8, 2026-8-22 07:51 , Processed in 0.134308 second(s), 52 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

    快速回复 返回顶部 返回列表