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

[转载发布] Unlimited and Optimized Pictures handle

[复制链接]
累计送礼:
0 个
累计收礼:
1 个
  • TA的每日心情
    开心
    4 天前
  • 签到天数: 209 天

    连续签到: 2 天

    [LV.7]常住居民III

    4585

    主题

    864

    回帖

    2万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

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

    灌水之王

    发表于 昨天 18:30 | 显示全部楼层 |阅读模式
    Unlimited and Optimized Pictures handle


    Introduction
    These are just some modifications in the original script.

    Features
    Remove the auto created (100 default) image objects, and create the image objects dynamically, and when the "erase Picture" is called, it also erase the object.

    This doesn't create a object with empty values, it only relocate space for the used images.
    So, even if you use, "$gameScreen.showPicture(9999999,"Image_Name", 0, x, y, 100, 100, 255, 0);" it will not make the variable size 9999999.


    How to Use
    Just save the script as a .js file and add it to your project.

    Plugin Commands / Script Calls
    The same from original.
    As the engine has a limite of 100 when calling throug "Show Picture", use "$gameScreen.showPicture" function.
    Example:
                    JavaScript:       
    1. $gameScreen.showPicture(
    2.   id, name, origin, x, y, scaleX, scaleY, opacity, blendMode);
    3. //Like
    4. $gameScreen.showPicture(9999999,"Image_Name", 0, x, y, 100, 100, 255, 0);
    复制代码

    You can use any "id" you want.
    Like:
                    JavaScript:       
    1. $gameScreen.showPicture("Nun","People2_6", 1, 0, 0, 100, 100, 255, 0);
    2. $gameScreen.showPicture("Doggy","Nature_1", 1, 0, 0, 100, 100, 255, 0);
    复制代码


    Script
                    JavaScript:       
    1. var ImageController = undefined;
    2. Game_Screen.prototype.maxPictures = function() {
    3.     return 0;  // Added Line to remove the auto created pictures object
    4. };
    5. Spriteset_Base.prototype.initialize = function() {
    6.     Sprite.prototype.initialize.call(this);
    7.     this.setFrame(0, 0, Graphics.width, Graphics.height);
    8.     this.loadSystemImages();
    9.     this.createLowerLayer();
    10.     this.createUpperLayer();
    11.     this._animationSprites = [];
    12.     ImageController = this; //Added line only to set the ImageController variable
    13. };
    14. Game_Screen.prototype.showPicture = function(pictureId, name, origin, x, y, scaleX, scaleY, opacity, blendMode) {
    15.     const realPictureId = this.realPictureId(pictureId);
    16.     if(ImageController._pictureContainer.children.find(picture => picture._pictureId == realPictureId) == undefined) {//Added line to check if the picture already exist
    17.         ImageController._pictureContainer.addChild(new Sprite_Picture(realPictureId))  //Added line to create the picture object and add it to the container
    18.         const picture = new Game_Picture();
    19.         picture.show(name, origin, x, y, scaleX, scaleY, opacity, blendMode);
    20.         picture.id = realPictureId;
    21.         if(this._pictures.length > 0)
    22.             {
    23.                 const ThisPictureIndex = this._pictures.indexOf(this._pictures.find(picture => picture === undefined));
    24.                 if(ThisPictureIndex != -1) {
    25.                     this._pictures[ThisPictureIndex] = picture;
    26.                     return;
    27.                 } else {
    28.                     this._pictures.push(picture);
    29.                     return;
    30.                 }
    31.             }
    32.         else
    33.             this._pictures.push(picture)
    34.     } else {
    35.         $gameScreen.erasePicture(realPictureId);
    36.         $gameScreen.showPicture(pictureId, name, origin, x, y, scaleX, scaleY, opacity, blendMode);
    37.     }
    38. };
    39. Game_Screen.prototype.picture = function(pictureId) {
    40.     const realPictureId = this.realPictureId(pictureId);
    41.     return this._pictures.find(function(picture) {
    42.         if(picture)
    43.             return picture.id === realPictureId
    44.         else
    45.             return false;
    46.     });
    47. };
    48. Sprite_Picture.prototype.remove = function() {
    49.     this.parent.removeChild(this);
    50. };
    51. Game_Screen.prototype.erasePicture = function(pictureId) {
    52.     const realPictureId = this.realPictureId(pictureId);
    53.     this._pictures[this._pictures.indexOf($gameScreen.picture(realPictureId))] = undefined;
    54.     //this._pictures[realPictureId] = null;
    55.     const picture = ImageController._pictureContainer.children.find(picture => picture._pictureId == realPictureId);
    56.     if(picture)
    57.         picture.remove(); //Added line to remove the picture object from the container
    58. };
    59. Game_Screen.prototype.realPictureId = function(pictureId) {
    60.     return pictureId;   //This was changed to only return the same pictureId inserted, function was not removed to keep compatibility with other plugins
    61. };
    复制代码


    Terms and Credits
    Use it however you like, no need to give me credit, since it's just a modification of the original script.


    本贴来自国际rpgmaker官方论坛作者:Naemegashi Yokohuro处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/unlimited-and-optimized-pictures-handle.147871/
    天天去同能,天天有童年!
    回复 送礼论坛版权

    使用道具 举报

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

    本版积分规则

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

    幸运抽奖

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

    立即查看

    聊天机器人
    Loading...

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

    GMT+8, 2026-7-16 12:59 , Processed in 0.142179 second(s), 52 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

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